Skip to content

Commit ecb41cf

Browse files
committed
fix: fix cypress component testing setup in bare mode
1 parent bac1c81 commit ecb41cf

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ jobs:
171171
run: pnpm --filter '*${{ matrix.e2e-framework }}*' --filter '!*bare*' --workspace-concurrency 1 test:e2e
172172

173173
- name: Cypress component testing for projects without Vitest
174+
working-directory: ./playground
174175
if: ${{ contains(matrix.e2e-framework, 'cypress') }}
175176
run: pnpm --filter '*cypress*' --filter '!*vitest*' --workspace-concurrency 1 test:unit
176177

index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ async function init() {
628628
}
629629

630630
if (argv.bare) {
631-
removeCSSImport(root, needsTypeScript)
631+
removeCSSImport(root, needsTypeScript, needsCypressCT)
632632
if (needsRouter) {
633633
emptyRouterConfig(root, needsTypeScript)
634634
}

utils/trimBoilerplate.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,24 @@ export function trimBoilerplate(rootDir: string) {
2020
}
2121
}
2222

23-
export function removeCSSImport(rootDir: string, needsTypeScript: boolean) {
23+
export function removeCSSImport(
24+
rootDir: string,
25+
needsTypeScript: boolean,
26+
needsCypressCT: boolean,
27+
) {
2428
// Remove CSS import in the entry file
2529
const entryPath = path.resolve(rootDir, needsTypeScript ? 'src/main.ts' : 'src/main.js')
2630
replaceContent(entryPath, (content) => content.replace("import './assets/main.css'\n\n", ''))
31+
32+
if (needsCypressCT) {
33+
const ctSetupPath = path.resolve(
34+
rootDir,
35+
needsTypeScript ? 'cypress/support/component.ts' : 'cypress/support/component.js',
36+
)
37+
replaceContent(ctSetupPath, (content) =>
38+
content.replace("import '@/assets/main.css'", "// import '@/assets/main.css'"),
39+
)
40+
}
2741
}
2842

2943
export function emptyRouterConfig(rootDir: string, needsTypeScript: boolean) {

0 commit comments

Comments
 (0)