Skip to content

Commit b556ee6

Browse files
authored
chore: brush up playwright-test types (#6928)
1 parent f745bf1 commit b556ee6

File tree

9 files changed

+867
-910
lines changed

9 files changed

+867
-910
lines changed

src/test/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
*/
1616

1717
import * as fs from 'fs';
18-
import { test as base } from './internal';
1918
import type { LaunchOptions, BrowserContextOptions, Page } from '../../types/types';
20-
import type { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from '../../types/test';
19+
import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from '../../types/test';
20+
import { rootTestType } from './testType';
2121

22-
export * from './internal';
23-
export const test = base.extend<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>({
22+
export { expect } from './expect';
23+
export const _baseTest: TestType<{}, {}> = rootTestType.test;
24+
export const test = _baseTest.extend<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>({
2425
defaultBrowserType: [ 'chromium', { scope: 'worker' } ],
2526
browserName: [ ({ defaultBrowserType }, use) => use(defaultBrowserType), { scope: 'worker' } ],
2627
playwright: [ require('../inprocess'), { scope: 'worker' } ],

src/test/internal.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/test/types.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
export * from '../../types/testInternal';
17+
import type { Fixtures } from '../../types/test';
18+
export * from '../../types/test';
19+
20+
export type Location = { file: string, line: number, column: number };
21+
export type FixturesWithLocation = {
22+
fixtures: Fixtures;
23+
location: Location;
24+
};

tests/playwright-test/basic.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ test('should focus test from one runTests', async ({ runInlineTest }) => {
241241
test('should work with default export', async ({ runInlineTest }) => {
242242
const result = await runInlineTest({
243243
'file.spec.ts': `
244-
import t from ${JSON.stringify(path.join(__dirname, 'playwright-test-internal'))};
244+
import t from ${JSON.stringify(path.join(__dirname, 'entry'))};
245245
t('passed', () => {
246246
t.expect(1 + 1).toBe(2);
247247
});

tests/playwright-test/playwright-test-internal.js renamed to tests/playwright-test/entry/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
* limitations under the License.
1515
*/
1616

17-
module.exports = require('../../lib/test/internal');
17+
export * from '../../../types/test';

tests/playwright-test/playwright-test-internal.d.ts renamed to tests/playwright-test/entry/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@
1414
* limitations under the License.
1515
*/
1616

17-
import type { TestType } from '../../types/testInternal';
18-
import type { Expect } from '../../types/testExpect';
19-
export type { Project, Config, TestStatus, TestInfo, WorkerInfo, TestType, Fixtures, TestFixture, WorkerFixture } from '../../types/testInternal';
20-
export const test: TestType<{}, {}>;
21-
export default test;
22-
export const expect: Expect;
17+
module.exports = require('../../../lib/test/index');

tests/playwright-test/playwright-test-fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Env = { [key: string]: string | number | boolean | undefined };
4848
async function writeFiles(testInfo: TestInfo, files: Files) {
4949
const baseDir = testInfo.outputPath();
5050

51-
const internalPath = JSON.stringify(path.join(__dirname, 'playwright-test-internal'));
51+
const internalPath = JSON.stringify(path.join(__dirname, 'entry'));
5252
const headerJS = `
5353
const folio = require(${internalPath});
5454
`;

0 commit comments

Comments
 (0)