Skip to content

Commit

Permalink
fix: ignore json files which do not contain test/fixtures (#7187)
Browse files Browse the repository at this point in the history
* ignore json files which do not contain test/fixtures

* BUMB version

* release: use rc

Co-authored-by: Andrey Belym <belym.a.2105@gmail.com>
  • Loading branch information
AlexKamaev and AndreyBelym committed Jul 22, 2022
1 parent 9b348de commit 5d0c87a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .publishrc
Expand Up @@ -8,7 +8,7 @@
"gitTag": true
},
"confirm": false,
"publishTag": "latest",
"publishTag": "rc",
"prePublishScript": "gulp test-server",
"postPublishScript": "gulp docker-publish"
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "testcafe",
"description": "Automated browser testing for the modern web development stack.",
"license": "MIT",
"version": "1.20.0",
"version": "1.20.1-rc.1",
"author": {
"name": "Developer Express Inc.",
"url": "https://www.devexpress.com/"
Expand Down
12 changes: 10 additions & 2 deletions src/compiler/test-file/formats/dev-tools/compiler.ts
Expand Up @@ -47,15 +47,23 @@ export default class DevToolsTestFileCompiler extends RawTestFileCompiler {
compile (code: string, filename: string): Test[] {
this.raw = JSON.parse(TEST_BASE);

return super.compile(this._preProcess(code), filename);
const preprocessedCode = this._preProcess(code);

if (!preprocessedCode)
return [];

return super.compile(preprocessedCode, filename);
}

_preProcess (code: string): string {
_preProcess (code: string): string | null {
const parsedCode = JSON.parse(code);

this._fixture.name = parsedCode.title;
this._test.name = parsedCode.title;

if (!parsedCode.steps)
return null;

parsedCode.steps.forEach((step: DevToolsRecorderStep, i: number) => this._processStep(step, i));

return JSON.stringify(this.raw);
Expand Down
10 changes: 10 additions & 0 deletions test/functional/fixtures/api/json/test.js
Expand Up @@ -57,4 +57,14 @@ describe('[API] DevTools Compiler', function () {
expect(errs[0]).contains('shadow button clicked');
});
});

it('JSON without tests', function () {
return runTests('./testcafe-fixtures/json-without-test.json', null, {
only: 'chrome',
shouldFail: true,
})
.catch(err => {
expect(err.message).contains('Source files do not contain valid \'fixture\' and \'test\' declarations.');
});
});
});
@@ -0,0 +1,3 @@
{
"custom": "json"
}

0 comments on commit 5d0c87a

Please sign in to comment.