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

refactor: refactor disableConcurrency from function to getter #8068

Merged
merged 11 commits into from
Nov 9, 2023
2 changes: 1 addition & 1 deletion src/api/structure/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions test/server/api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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"`);
}
});
});
});
4 changes: 4 additions & 0 deletions ts-defs-src/test-api/structure.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ interface FixtureFn {
* Disables page reloading which would happen right before each test in this fixture.
*/
disablePageReloads: this;
/**
* Disables global concurrency setting for this fixture.
aleks-pro marked this conversation as resolved.
Show resolved Hide resolved
*/
disableConcurrency: this;
/**
* Specifies the additional information for all tests in the fixture. This information can be used in reports.
*
Expand Down
Loading