Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"lint-staged": "catalog:",
"oxfmt": "catalog:",
"oxlint": "catalog:",
"playwright": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
"vitest": "catalog:"
Expand Down
30 changes: 25 additions & 5 deletions packages/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ async function createShimForExport(
// Check if it's a type-only export
if (exportValue.endsWith('.d.ts')) {
const dtsPath = join(shimDirForFile, `${baseFileName}.d.ts`);
await writeFile(dtsPath, `export * from '${testImportSpecifier}';\n`);
// Include side-effect import to preserve module augmentations (e.g., toMatchSnapshot on Assertion)
await writeFile(
dtsPath,
`import '${testImportSpecifier}';\nexport * from '${testImportSpecifier}';\n`,
);
return { types: `./dist/test/${shimBaseName}.d.ts` };
}

Expand Down Expand Up @@ -184,7 +188,11 @@ async function createShimForExport(

if (value.types && typeof value.types === 'string') {
const dtsPath = join(shimDirForFile, `${baseFileName}.d.ts`);
await writeFile(dtsPath, `export * from '${testImportSpecifier}';\n`);
// Include side-effect import to preserve module augmentations (e.g., toMatchSnapshot on Assertion)
await writeFile(
dtsPath,
`import '${testImportSpecifier}';\nexport * from '${testImportSpecifier}';\n`,
);
(result as Record<string, string>).types = `./dist/test/${shimBaseName}.d.ts`;
}

Expand Down Expand Up @@ -220,7 +228,11 @@ async function createConditionalShim(
// Handle top-level types (flat structure like { types, require, default })
if (value.types && typeof value.types === 'string' && !value.import) {
const dtsPath = join(shimDir, `${baseFileName}.d.ts`);
await writeFile(dtsPath, `export * from '${testImportSpecifier}';\n`);
// Include side-effect import to preserve module augmentations (e.g., toMatchSnapshot on Assertion)
await writeFile(
dtsPath,
`import '${testImportSpecifier}';\nexport * from '${testImportSpecifier}';\n`,
);
(result as Record<string, string>).types = `./dist/test/${shimBaseName}.d.ts`;
}

Expand All @@ -244,7 +256,11 @@ async function createConditionalShim(

if (importValue.types && typeof importValue.types === 'string') {
const dtsPath = join(shimDir, `${baseFileName}.d.ts`);
await writeFile(dtsPath, `export * from '${testImportSpecifier}';\n`);
// Include side-effect import to preserve module augmentations (e.g., toMatchSnapshot on Assertion)
await writeFile(
dtsPath,
`import '${testImportSpecifier}';\nexport * from '${testImportSpecifier}';\n`,
);
importResult.types = `./dist/test/${shimBaseName}.d.ts`;
}

Expand Down Expand Up @@ -276,7 +292,11 @@ async function createConditionalShim(

if (requireValue.types && typeof requireValue.types === 'string') {
const dctsPath = join(shimDir, `${baseFileName}.d.cts`);
await writeFile(dctsPath, `export * from '${testImportSpecifier}';\n`);
// Include side-effect import to preserve module augmentations (e.g., toMatchSnapshot on Assertion)
await writeFile(
dctsPath,
`import '${testImportSpecifier}';\nexport * from '${testImportSpecifier}';\n`,
);
requireResult.types = `./dist/test/${shimBaseName}.d.cts`;
}

Expand Down
16 changes: 16 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
"types": "./dist/test/context.d.ts",
"default": "./dist/test/context.js"
},
"./test/browser/context": {
"types": "./dist/test/browser/context.d.ts",
"default": "./dist/test/browser/context.js"
},
"./test/locators": {
"default": "./dist/test/locators.js"
},
Expand All @@ -176,6 +180,18 @@
"types": "./dist/test/browser-preview.d.ts",
"default": "./dist/test/browser-preview.js"
},
"./test/browser/providers/playwright": {
"types": "./dist/test/browser/providers/playwright.d.ts",
"default": "./dist/test/browser/providers/playwright.js"
},
"./test/browser/providers/webdriverio": {
"types": "./dist/test/browser/providers/webdriverio.d.ts",
"default": "./dist/test/browser/providers/webdriverio.js"
},
"./test/browser/providers/preview": {
"types": "./dist/test/browser/providers/preview.d.ts",
"default": "./dist/test/browser/providers/preview.js"
},
"./test/plugins/runner": {
"default": "./dist/test/plugins/runner.js"
},
Expand Down
Loading
Loading