diff --git a/src/test-run/index.ts b/src/test-run/index.ts index 0063bceef20..fd15e72b895 100644 --- a/src/test-run/index.ts +++ b/src/test-run/index.ts @@ -1443,8 +1443,10 @@ export default class TestRun extends AsyncEventEmitter { } public async initialize (): Promise { - await this._clearCookiesAndStorages(); - await this._initRequestHooks(); + if (!this.test.skip) { + await this._clearCookiesAndStorages(); + await this._initRequestHooks(); + } } private async _clearCookiesAndStorages (): Promise { diff --git a/test/functional/fixtures/api/es-next/request-hooks/test.js b/test/functional/fixtures/api/es-next/request-hooks/test.js index 86f680a67da..425df76e65b 100644 --- a/test/functional/fixtures/api/es-next/request-hooks/test.js +++ b/test/functional/fixtures/api/es-next/request-hooks/test.js @@ -127,5 +127,9 @@ describe('Request Hooks', () => { it('Set custom header on "onRequest" method (GH-7846)', () => { return runTests('./testcafe-fixtures/api/7846.js', null, { only: 'chrome' }); }); + + it('Request hook on skipped test should not affect next test (GH-8229)', () => { + return runTests('./testcafe-fixtures/api/8229.js', null, { only: 'chrome' }); + }); }); }); diff --git a/test/functional/fixtures/api/es-next/request-hooks/testcafe-fixtures/api/8229.js b/test/functional/fixtures/api/es-next/request-hooks/testcafe-fixtures/api/8229.js new file mode 100644 index 00000000000..3de85284fac --- /dev/null +++ b/test/functional/fixtures/api/es-next/request-hooks/testcafe-fixtures/api/8229.js @@ -0,0 +1,20 @@ +import { RequestMock, Selector } from 'testcafe'; + +const PAGE_URL = 'http://localhost:3000/fixtures/api/es-next/request-hooks/pages/api/empty.html'; + +fixture('Fixture') + .page(PAGE_URL); + +test('before the skipped', async t => { + await t.expect(Selector('h1').exists).ok(); +}); + +test.skip.requestHooks( + RequestMock().onRequestTo(/.*empty*/).respond('', 404) +)('skipped', async t => { + await t.expect(Selector('h1').exists).ok(); +}); + +test('after the skipped', async t => { + await t.expect(Selector('h1').exists).ok(); +});