Skip to content

Commit

Permalink
feat: Add tests for skipped tests (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielku15 authored May 20, 2024
1 parent 9b72080 commit da0fcce
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 8 deletions.
12 changes: 6 additions & 6 deletions .vscode-ci-test-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ module.exports = class MultiReporter extends BaseReporter {
console.log(' '.repeat(indent * 2) + txt)
}

runner.once(Mocha.Runner.constants.EVENT_RUN_BEGIN, () => {
runner.on(Mocha.Runner.constants.EVENT_RUN_BEGIN, () => {
log('Begin Run')
indent++;
});
runner.once(Mocha.Runner.constants.EVENT_RUN_END, () => {
runner.on(Mocha.Runner.constants.EVENT_RUN_END, () => {
indent--;
log('End Run')
});
runner.once(Mocha.Runner.constants.EVENT_SUITE_BEGIN, (suite) => {
runner.on(Mocha.Runner.constants.EVENT_SUITE_BEGIN, (suite) => {
log(`Begin Suite '${suite.titlePath()}'`)
indent++;
});
runner.once(Mocha.Runner.constants.EVENT_SUITE_END, (suite) => {
runner.on(Mocha.Runner.constants.EVENT_SUITE_END, (suite) => {
indent--;
log(`End Suite '${suite.titlePath()}'`)
});
runner.once(Mocha.Runner.constants.EVENT_TEST_BEGIN, (test) => {
runner.on(Mocha.Runner.constants.EVENT_TEST_BEGIN, (test) => {
log(`Begin Test '${test.title}'`)
indent++;
});
runner.once(Mocha.Runner.constants.EVENT_TEST_END, (test) => {
runner.on(Mocha.Runner.constants.EVENT_TEST_END, (test) => {
indent--;
log(`End Test '${test.title}'`)
});
Expand Down
2 changes: 1 addition & 1 deletion src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Controller {

const rescan = async (reason: string) => {
try {
logChannel.info(`Rescan of tests triggered (${reason})`);
logChannel.info(`Rescan of tests triggered (${reason}) - ${this.configFile.uri}}`);
this.recreateDiscoverer();
await this.scanFiles();
} catch (e) {
Expand Down
45 changes: 44 additions & 1 deletion src/test/integration/simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ describe('simple', () => {
['folder', [['nested.test.js', [['is nested']]]]],
['goodbye.test.js', [['math', [['division']]]]],
['hello.test.js', [['math', [['addition'], ['subtraction']]]]],
[
'skip.test.js',
[
['skip-suite-1', [['addition'], ['subtraction']]],
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
]);
});

Expand All @@ -44,6 +51,13 @@ describe('simple', () => {
await expectTestTree(c, [
['folder', [['nested.test.js', [['is nested']]]]],
['goodbye.test.js', [['math', [['division']]]]],
[
'skip.test.js',
[
['skip-suite-1', [['addition'], ['subtraction']]],
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
]);
});

Expand All @@ -57,6 +71,13 @@ describe('simple', () => {
await expectTestTree(c, [
['goodbye.test.js', [['math', [['division']]]]],
['hello.test.js', [['math', [['addition'], ['subtraction']]]]],
[
'skip.test.js',
[
['skip-suite-1', [['addition'], ['subtraction']]],
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
]);
});

Expand All @@ -78,6 +99,13 @@ describe('simple', () => {
['folder', [['nested.test.js', [['is nested']]]]],
['goodbye.test.js', [['math', [['division']]]]],
['hello.test.js', [['subtraction']]],
[
'skip.test.js',
[
['skip-suite-1', [['addition'], ['subtraction']]],
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
]);
});

Expand All @@ -100,6 +128,10 @@ describe('simple', () => {
'hello.test.js/math/addition': ['enqueued', 'started', 'passed'],
'hello.test.js/math/subtraction': ['enqueued', 'started', 'passed'],
'folder/nested.test.js/is nested': ['enqueued', 'started', 'passed'],
'skip.test.js/skip-suite-1/addition': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-1/subtraction': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-2/addition': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-2/subtraction': ['enqueued', 'started', 'passed'],
});
});

Expand Down Expand Up @@ -182,6 +214,10 @@ describe('simple', () => {

run.expectStates({
'goodbye.test.js/math/division': ['enqueued', 'started', 'passed'],
'skip.test.js/skip-suite-1/addition': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-1/subtraction': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-2/addition': ['enqueued', 'skipped'],
'skip.test.js/skip-suite-2/subtraction': ['enqueued', 'started', 'passed'],
});
});

Expand All @@ -198,12 +234,19 @@ describe('simple', () => {
while (!ok) {
updated += '\n//';
await fs.writeFile(configPath, updated);
ok = await Promise.race([onChange.then(() => true), setTimeout(500)]);
ok = await Promise.race([onChange.then(() => true), setTimeout(1000)]);
}

await expectTestTree(c, [
['goodbye.test.js', [['math', [['division']]]]],
['hello.test.js', [['math', [['addition'], ['subtraction']]]]],
[
'skip.test.js',
[
['skip-suite-1', [['addition'], ['subtraction']]],
['skip-suite-2', [['addition'], ['subtraction']]],
],
],
]);
});
});
21 changes: 21 additions & 0 deletions test-workspaces/simple/skip.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { strictEqual } = require('node:assert');

describe.skip('skip-suite-1', () => {
it('addition', async () => {
strictEqual(1 + 1, 2);
});

it('subtraction', async () => {
strictEqual(1 - 1, 0);
});
});

describe('skip-suite-2', () => {
it.skip('addition', async () => {
strictEqual(1 + 1, 2);
});

it('subtraction', async () => {
strictEqual(1 - 1, 0);
});
});

0 comments on commit da0fcce

Please sign in to comment.