Skip to content

Commit 5d0c87a

Browse files
fix: ignore json files which do not contain test/fixtures (#7187)
* ignore json files which do not contain test/fixtures * BUMB version * release: use rc Co-authored-by: Andrey Belym <[email protected]>
1 parent 9b348de commit 5d0c87a

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

.publishrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"gitTag": true
99
},
1010
"confirm": false,
11-
"publishTag": "latest",
11+
"publishTag": "rc",
1212
"prePublishScript": "gulp test-server",
1313
"postPublishScript": "gulp docker-publish"
1414
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "testcafe",
33
"description": "Automated browser testing for the modern web development stack.",
44
"license": "MIT",
5-
"version": "1.20.0",
5+
"version": "1.20.1-rc.1",
66
"author": {
77
"name": "Developer Express Inc.",
88
"url": "https://www.devexpress.com/"

src/compiler/test-file/formats/dev-tools/compiler.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,23 @@ export default class DevToolsTestFileCompiler extends RawTestFileCompiler {
4747
compile (code: string, filename: string): Test[] {
4848
this.raw = JSON.parse(TEST_BASE);
4949

50-
return super.compile(this._preProcess(code), filename);
50+
const preprocessedCode = this._preProcess(code);
51+
52+
if (!preprocessedCode)
53+
return [];
54+
55+
return super.compile(preprocessedCode, filename);
5156
}
5257

53-
_preProcess (code: string): string {
58+
_preProcess (code: string): string | null {
5459
const parsedCode = JSON.parse(code);
5560

5661
this._fixture.name = parsedCode.title;
5762
this._test.name = parsedCode.title;
5863

64+
if (!parsedCode.steps)
65+
return null;
66+
5967
parsedCode.steps.forEach((step: DevToolsRecorderStep, i: number) => this._processStep(step, i));
6068

6169
return JSON.stringify(this.raw);

test/functional/fixtures/api/json/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,14 @@ describe('[API] DevTools Compiler', function () {
5757
expect(errs[0]).contains('shadow button clicked');
5858
});
5959
});
60+
61+
it('JSON without tests', function () {
62+
return runTests('./testcafe-fixtures/json-without-test.json', null, {
63+
only: 'chrome',
64+
shouldFail: true,
65+
})
66+
.catch(err => {
67+
expect(err.message).contains('Source files do not contain valid \'fixture\' and \'test\' declarations.');
68+
});
69+
});
6070
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"custom": "json"
3+
}

0 commit comments

Comments
 (0)