diff --git a/src/api/structure/fixture.ts b/src/api/structure/fixture.ts index 2198ef6e73b..d55cdc2ea93 100644 --- a/src/api/structure/fixture.ts +++ b/src/api/structure/fixture.ts @@ -62,7 +62,7 @@ export default class Fixture extends TestingUnit { return this.apiOrigin; } - private _disableConcurrency$ (): Function { + private _disableConcurrency$getter (): Function { this.disableConcurrency = true; return this.apiOrigin; diff --git a/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-and-one-fixture-test.js b/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-and-one-fixture-test.js index 2a4f6cef2e9..fd7a5ee4fcb 100644 --- a/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-and-one-fixture-test.js +++ b/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-and-one-fixture-test.js @@ -12,7 +12,7 @@ fixture `no concurrent fixture` await t.expect(Object.keys(connectionsFixture).length).eql(1); }) .page `http://localhost:3000/fixtures/regression/gh-2011/pages/index.html` - .disableConcurrency(); + .disableConcurrency; test('long concurrent test 1', async t => { await t.wait(5000); diff --git a/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-all-test.js b/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-all-test.js index cf149d1cbd1..48432c110a5 100644 --- a/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-all-test.js +++ b/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-all-test.js @@ -33,7 +33,7 @@ fixture `fixture 1` .after(() => { assertSingleConnection(connectionsFixture1); }) - .disableConcurrency(); + .disableConcurrency; for (let i = 0; i < TEST_COUNT; i++) { test(`fixture 1 - test ${i}`, async () => { @@ -50,7 +50,7 @@ fixture `fixture 2` .after(() => { assertSingleConnection(connectionsFixture2); }) - .disableConcurrency(); + .disableConcurrency; for (let i = 0; i < TEST_COUNT; i++) { test(`fixture 2 - test ${i}`, async () => { @@ -67,7 +67,7 @@ fixture `fixture 3` .after(() => { assertSingleConnection(connectionsFixture3); }) - .disableConcurrency(); + .disableConcurrency; for (let i = 0; i < TEST_COUNT; i++) { test(`fixture 3 - test ${i}`, async () => { diff --git a/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-test.js b/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-test.js index 66991cd7bde..becd8f2d066 100644 --- a/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-test.js +++ b/test/functional/fixtures/regression/gh-2011/testcafe-fixtures/concurrency-mode-with-disable-concurrency-fixture-test.js @@ -34,7 +34,7 @@ fixture `no concurrent fixture` await t.expect(Object.keys(connectionsFixture2).length).eql(1); }) .page `http://localhost:3000/fixtures/regression/gh-2011/pages/index.html` - .disableConcurrency(); + .disableConcurrency; test('long concurrent test 1', async t => { await t.wait(5000); diff --git a/test/server/api-test.js b/test/server/api-test.js index 0b2076400f9..6c71d982a03 100644 --- a/test/server/api-test.js +++ b/test/server/api-test.js @@ -7,6 +7,7 @@ const compile = require('./helpers/compile'); const OPTION_NAMES = require('../../lib/configuration/option-names'); const Compiler = require('../../lib/compiler'); const { RUNTIME_ERRORS } = require('../../lib/errors/types'); +const Fixture = require('../../lib/api/structure/fixture'); describe('API', function () { @@ -1862,4 +1863,26 @@ describe('API', function () { expect(configuration.getOption(OPTION_NAMES.disableHttp2)).be.true; }); }); + + describe('API Methods Validation', () => { + it('Should checks all methods', async () => { + const GETTER_API_METHODS = ['only', 'skip', 'disablePageReloads', 'enablePageReloads', 'disablePageCaching', 'disableConcurrency']; + const FUNCTIONS_API_METHODS = ['page', 'skipJsErrors', 'httpAuth', 'meta', 'before', 'after', 'beforeEach', 'afterEach', 'requestHooks', 'clientScripts']; + + for (const apiMethod of Fixture.API_LIST) { + if (!GETTER_API_METHODS.includes(apiMethod.apiProp) && !FUNCTIONS_API_METHODS.includes(apiMethod.apiProp)) { + throw new Error(`Please, check the "${apiMethod.srcProp}" method. + If the method doesn't accept any arguments, ensure that the method is implemented as a 'getter' and add the method name to GETTER_API_METHODS. + If the method accepts arguments, ensure that the method is implemented as a 'function' and add the method name to FUNCTIONS_API_METHODS. + `); + } + + if (GETTER_API_METHODS.includes(apiMethod.apiProp) && apiMethod.accessor !== 'getter') + throw new Error(`Make sure that the method "${apiMethod.srcProp}" is implemented as a "getter"`); + + if (FUNCTIONS_API_METHODS.includes(apiMethod.apiProp) && apiMethod.accessor) + throw new Error(`Make sure that the method "${apiMethod.srcProp}" is implemented as a "function"`); + } + }); + }); }); diff --git a/ts-defs-src/test-api/structure.d.ts b/ts-defs-src/test-api/structure.d.ts index dfb0c72595b..0697ca8c790 100644 --- a/ts-defs-src/test-api/structure.d.ts +++ b/ts-defs-src/test-api/structure.d.ts @@ -110,6 +110,10 @@ interface FixtureFn { * Disables page reloading which would happen right before each test in this fixture. */ disablePageReloads: this; + /** + * Disables the global concurrency setting for this fixture. + */ + disableConcurrency: this; /** * Specifies the additional information for all tests in the fixture. This information can be used in reports. *