Skip to content

Commit

Permalink
chore: brush up playwright-test types (#6928)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman authored Jun 7, 2021
1 parent f745bf1 commit b556ee6
Show file tree
Hide file tree
Showing 9 changed files with 867 additions and 910 deletions.
9 changes: 5 additions & 4 deletions src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*/

import * as fs from 'fs';
import { test as base } from './internal';
import type { LaunchOptions, BrowserContextOptions, Page } from '../../types/types';
import type { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from '../../types/test';
import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from '../../types/test';
import { rootTestType } from './testType';

export * from './internal';
export const test = base.extend<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>({
export { expect } from './expect';
export const _baseTest: TestType<{}, {}> = rootTestType.test;
export const test = _baseTest.extend<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>({
defaultBrowserType: [ 'chromium', { scope: 'worker' } ],
browserName: [ ({ defaultBrowserType }, use) => use(defaultBrowserType), { scope: 'worker' } ],
playwright: [ require('../inprocess'), { scope: 'worker' } ],
Expand Down
25 changes: 0 additions & 25 deletions src/test/internal.ts

This file was deleted.

9 changes: 8 additions & 1 deletion src/test/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@
* limitations under the License.
*/

export * from '../../types/testInternal';
import type { Fixtures } from '../../types/test';
export * from '../../types/test';

export type Location = { file: string, line: number, column: number };
export type FixturesWithLocation = {
fixtures: Fixtures;
location: Location;
};
2 changes: 1 addition & 1 deletion tests/playwright-test/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ test('should focus test from one runTests', async ({ runInlineTest }) => {
test('should work with default export', async ({ runInlineTest }) => {
const result = await runInlineTest({
'file.spec.ts': `
import t from ${JSON.stringify(path.join(__dirname, 'playwright-test-internal'))};
import t from ${JSON.stringify(path.join(__dirname, 'entry'))};
t('passed', () => {
t.expect(1 + 1).toBe(2);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

module.exports = require('../../lib/test/internal');
export * from '../../../types/test';
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@
* limitations under the License.
*/

import type { TestType } from '../../types/testInternal';
import type { Expect } from '../../types/testExpect';
export type { Project, Config, TestStatus, TestInfo, WorkerInfo, TestType, Fixtures, TestFixture, WorkerFixture } from '../../types/testInternal';
export const test: TestType<{}, {}>;
export default test;
export const expect: Expect;
module.exports = require('../../../lib/test/index');
2 changes: 1 addition & 1 deletion tests/playwright-test/playwright-test-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Env = { [key: string]: string | number | boolean | undefined };
async function writeFiles(testInfo: TestInfo, files: Files) {
const baseDir = testInfo.outputPath();

const internalPath = JSON.stringify(path.join(__dirname, 'playwright-test-internal'));
const internalPath = JSON.stringify(path.join(__dirname, 'entry'));
const headerJS = `
const folio = require(${internalPath});
`;
Expand Down
Loading

0 comments on commit b556ee6

Please sign in to comment.