Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add Cypress to the project #510

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ yarn-error.log*
.turbo

*.tsbuildinfo

#cypress screenshots and videos
apps/app/cypress/screenshots
apps/app/cypress/videos
2 changes: 1 addition & 1 deletion apps/app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
root: true,
extends: ["devfaq", "plugin:storybook/recommended"],
extends: ["devfaq", "plugin:storybook/recommended", "plugin:cypress/recommended"],
parserOptions: {
tsconfigRootDir: __dirname,
},
Expand Down
10 changes: 10 additions & 0 deletions apps/app/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
// setupNodeEvents(on, config) {
// implement node event listeners here
// },
baseUrl: "http://app.devfaq.localhost:3000",
},
});
8 changes: 8 additions & 0 deletions apps/app/cypress/e2e/helloWorld.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe("hello world", () => {
it("visit home page", () => {
cy.visit("/");
cy.get("h1").should("contain", "DevFAQ");
});
});

export {};
5 changes: 5 additions & 0 deletions apps/app/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
39 changes: 39 additions & 0 deletions apps/app/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }

export {};
20 changes: 20 additions & 0 deletions apps/app/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')
6 changes: 5 additions & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"lint:fix": "next lint --dir . --fix --quiet",
"check-types": "tsc --noEmit",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
"build-storybook": "storybook build",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
"dependencies": {
"@headlessui/react": "1.7.7",
Expand Down Expand Up @@ -54,8 +56,10 @@
"@vitejs/plugin-react": "3.0.0",
"autoprefixer": "^10.4.13",
"css-loader": "^6.7.3",
"cypress": "12.5.1",
"eslint": "8.31.0",
"eslint-config-devfaq": "workspace:*",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-storybook": "^0.6.8",
"jsdom": "20.0.3",
"openapi-types": "workspace:*",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"lint:fix": "turbo run lint:fix --parallel",
"format": "prettier --write .",
"check-types": "turbo run check-types --parallel",
"prepare": "husky install"
"prepare": "husky install",
"cypress:open": "turbo run cypress:open",
"cypress:run": "turbo run cypress:run"
},
"resolutions": {
"@mdx-js/mdx": "2.1.5",
Expand Down
Loading