Skip to content

Commit

Permalink
chore: add component tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis committed Feb 24, 2023
1 parent 0b333e5 commit 697c417
Show file tree
Hide file tree
Showing 13 changed files with 694 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/webapp/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = defineConfig({
},

component: {
specPattern: "cypress/component/*.spec.js",
specPattern: ["pages/**/*.spec.tsx", "pages/*.spec.tsx"],
setupNodeEvents(on, config) {
return currents(on, config);
},
Expand Down
5 changes: 5 additions & 0 deletions examples/webapp/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
3 changes: 3 additions & 0 deletions examples/webapp/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
reactStrictMode: true,
};
9 changes: 8 additions & 1 deletion examples/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@
"version": "0.0.0",
"private": true,
"scripts": {
"build": "next build",
"start": "next start",
"cypress:script": "ts-node scripts/currents-script.ts"
},
"dependencies": {
"cypress": "^12.6.0",
"@currents/cypress": "*",
"cypress": "^12.6.0",
"cypress-terminal-report": "^5.0.0",
"next": "^13.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-node": "^10.9.1"
},
"devDependencies": {
"@types/node": "^17.0.12",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"eslint": "7.32.0",
"eslint-config-custom": "*",
"tsconfig": "*",
Expand Down
7 changes: 7 additions & 0 deletions examples/webapp/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function About() {
return (
<div>
<h1>About Page</h1>
</div>
);
}
10 changes: 10 additions & 0 deletions examples/webapp/pages/aboutAbout-failing.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import About from "./about";

describe("<About />", () => {
it("renders", () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<About />);
cy.contains("Not About Page");
});
});
10 changes: 10 additions & 0 deletions examples/webapp/pages/aboutAbout.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import About from "./about";

describe("<About />", () => {
it("renders", () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<About />);
cy.contains("About Page");
});
});
7 changes: 7 additions & 0 deletions examples/webapp/pages/another.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Another() {
return (
<div>
<h1>Another Page</h1>
</div>
);
}
10 changes: 10 additions & 0 deletions examples/webapp/pages/anotherAnother.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import Another from "./another";

describe("<Another />", () => {
it("renders", () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<Another />);
cy.contains("Another Page");
});
});
12 changes: 12 additions & 0 deletions examples/webapp/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Link from "next/link";

export default function Home() {
return (
<nav>
<Link href="/about">About</Link>
<Link href="/another">Another</Link>
</nav>
);
}

export {};
11 changes: 11 additions & 0 deletions examples/webapp/pages/indexHome.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import Home from "./index";

describe("<Home />", () => {
it("renders", () => {
// see: https://on.cypress.io/mounting-react
cy.mount(<Home />);
cy.contains("About");
cy.contains("Another");
});
});
2 changes: 1 addition & 1 deletion examples/webapp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"module": "CommonJS"
}
},
"include": ["src"],
"include": ["next-env.d.ts"],
"exclude": ["node_modules"]
}
Loading

0 comments on commit 697c417

Please sign in to comment.