Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore json files which do not contain test/fixtures #7187

Merged
merged 3 commits into from Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
}