Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit bf7bd3f

Browse files
committed
generate cypress fixtures
1 parent cc05a3b commit bf7bd3f

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
config: video=false
4242
browser: chrome
4343
spec: cypress/e2e/broken-links.cy.ts
44-
build: yarn build
44+
build: yarn cypress:build
4545
start: yarn start
4646
wait-on: 'http://localhost:3000'
4747
env:
@@ -66,7 +66,7 @@ jobs:
6666
config: video=false
6767
browser: chrome
6868
spec: cypress/e2e/a11y.cy.ts
69-
build: yarn build
69+
build: yarn cypress:build
7070
start: yarn start
7171
wait-on: 'http://localhost:3000'
7272
env:
@@ -91,7 +91,7 @@ jobs:
9191
config: video=false
9292
browser: chrome
9393
spec: cypress/e2e/seo.cy.ts
94-
build: yarn build
94+
build: yarn cypress:build
9595
start: yarn start
9696
wait-on: 'http://localhost:3000'
9797
env:

cypress.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:3000',
6+
setupNodeEvents(on, config) {
7+
// require("cypress-fail-fast/plugin")(on, config);
8+
return config
9+
},
10+
},
11+
})

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"format:check": "prettier --check src",
1313
"format:fix": "prettier --write src",
1414
"cypress": "cypress open",
15+
"cypress:fixtures": "node scripts/build-pages-fixture.mjs",
16+
"cypress:build": "yarn build && yarn cypress:fixtures",
1517
"lint-staged": "lint-staged"
1618
},
1719
"browserslist": "defaults, not ie <= 11",

scripts/build-pages-fixture.js

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

scripts/build-pages-fixture.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import fs from 'fs/promises'
2+
3+
import { allDocs } from '../.contentlayer/generated/index.mjs'
4+
5+
const FIXTURE_PATH = 'cypress/fixtures/pages.json'
6+
7+
async function run() {
8+
try {
9+
const paths = allDocs
10+
.map((doc) => {
11+
return doc.slug ? `/${doc.slug}` : '/'
12+
})
13+
.sort((a, b) => a.localeCompare(b))
14+
15+
console.log(`${paths.length} paths found. Generating fixture`)
16+
17+
await fs.writeFile(FIXTURE_PATH, JSON.stringify(paths))
18+
} catch (error) {
19+
console.log(error.message)
20+
21+
process.exit(1)
22+
}
23+
}
24+
25+
run()

0 commit comments

Comments
 (0)