From 5d0c87af438b286df9d93d9417f1e37e2d6c2039 Mon Sep 17 00:00:00 2001 From: AlexKamaev Date: Fri, 22 Jul 2022 20:20:59 +0400 Subject: [PATCH] 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 --- .publishrc | 2 +- package.json | 2 +- src/compiler/test-file/formats/dev-tools/compiler.ts | 12 ++++++++++-- test/functional/fixtures/api/json/test.js | 10 ++++++++++ .../json/testcafe-fixtures/json-without-test.json | 3 +++ 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 test/functional/fixtures/api/json/testcafe-fixtures/json-without-test.json diff --git a/.publishrc b/.publishrc index fe0e22548c6..ef370e94b52 100644 --- a/.publishrc +++ b/.publishrc @@ -8,7 +8,7 @@ "gitTag": true }, "confirm": false, - "publishTag": "latest", + "publishTag": "rc", "prePublishScript": "gulp test-server", "postPublishScript": "gulp docker-publish" } diff --git a/package.json b/package.json index b1185a21674..6e7d53fbec8 100644 --- a/package.json +++ b/package.json @@ -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/" diff --git a/src/compiler/test-file/formats/dev-tools/compiler.ts b/src/compiler/test-file/formats/dev-tools/compiler.ts index 3fa1ba7de07..2bd87141c14 100644 --- a/src/compiler/test-file/formats/dev-tools/compiler.ts +++ b/src/compiler/test-file/formats/dev-tools/compiler.ts @@ -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); diff --git a/test/functional/fixtures/api/json/test.js b/test/functional/fixtures/api/json/test.js index c6fbbacd2ae..b8b21df1f22 100644 --- a/test/functional/fixtures/api/json/test.js +++ b/test/functional/fixtures/api/json/test.js @@ -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.'); + }); + }); }); diff --git a/test/functional/fixtures/api/json/testcafe-fixtures/json-without-test.json b/test/functional/fixtures/api/json/testcafe-fixtures/json-without-test.json new file mode 100644 index 00000000000..26dca1e4289 --- /dev/null +++ b/test/functional/fixtures/api/json/testcafe-fixtures/json-without-test.json @@ -0,0 +1,3 @@ +{ + "custom": "json" +}