Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit fc54bbc

Browse files
authored
Merge pull request #21 from StaticJsCMS/feature/cypress
feat: add cypress test to ensure admin page is loading
2 parents e68ced4 + 403203f commit fc54bbc

File tree

6 files changed

+2105
-38
lines changed

6 files changed

+2105
-38
lines changed

cypress.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from "cypress";
2+
3+
export default defineConfig({
4+
projectId: "63isgs",
5+
fixturesFolder: false,
6+
7+
e2e: {
8+
baseUrl: "http://localhost:3000",
9+
supportFile: false,
10+
setupNodeEvents(on, config) {
11+
// implement node event listeners here
12+
},
13+
},
14+
});

cypress/e2e/admin.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export {};
2+
3+
describe("admin page", () => {
4+
it("loads", () => {
5+
cy.visit("/admin");
6+
cy.contains("button", "Login with Netlify Identity").should("be.visible");
7+
});
8+
});

netlify.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
[build]
2-
publish = ".next"
3-
command = "npm run build"
2+
publish = ".next"
3+
command = "npm run build"
4+
5+
[build.environment]
6+
# cache Cypress binary in local "node_modules" folder
7+
# so Netlify caches it
8+
CYPRESS_CACHE_FOLDER = "./node_modules/CypressBinary"
9+
10+
[[plugins]]
11+
package = "@netlify/plugin-nextjs"
412

513
[[plugins]]
6-
package = "@netlify/plugin-nextjs"
14+
# runs Cypress tests against the deployed URL
15+
package = "netlify-plugin-cypress"
16+
[plugins.inputs]
17+
record = true

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
"@types/js-yaml": "4.0.5",
3838
"@types/node": "18.14.5",
3939
"@types/react": "18.0.28",
40+
"cypress": "^12.7.0",
4041
"eslint-config-next": "13.2.3",
4142
"jest": "29.4.3",
4243
"js-yaml-loader": "1.2.2",
44+
"netlify-plugin-cypress": "^2.2.1",
4345
"ts-jest": "29.0.5",
4446
"typescript": "4.9.5"
4547
}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"resolveJsonModule": true,
1818
"isolatedModules": true,
1919
"jsx": "preserve",
20-
"incremental": true
20+
"incremental": true,
21+
"types": ["cypress", "node"]
2122
},
2223
"exclude": [
2324
"node_modules"

0 commit comments

Comments
 (0)