From 957a4c6ed56844d05f7256391a973fe04f5264c7 Mon Sep 17 00:00:00 2001 From: harryjrk Date: Sun, 15 Oct 2023 08:26:36 +0200 Subject: [PATCH] remove cypress for good --- .eslintrc.js | 7 ----- .github/workflows/deploy.yml | 34 ---------------------- .gitignore | 2 -- README.md | 26 ----------------- cypress.config.ts | 27 ----------------- package.json | 3 -- remix.init/gitignore | 2 -- remix.init/index.js | 56 ++++++------------------------------ tsconfig.json | 1 - 9 files changed, 9 insertions(+), 149 deletions(-) delete mode 100644 cypress.config.ts diff --git a/.eslintrc.js b/.eslintrc.js index 0a77191..f86628d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -117,13 +117,6 @@ module.exports = { }, }, - // Cypress - { - files: ["cypress/**/*.ts"], - plugins: ["cypress"], - extends: ["plugin:cypress/recommended", "prettier"], - }, - // Node { files: [".eslintrc.js", "mocks/**/*.js"], diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5623905..add533f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -76,40 +76,6 @@ jobs: - name: ⚡ Run vitest run: npm run test -- --coverage - # cypress: - # name: ⚫️ Cypress - # runs-on: ubuntu-latest - # steps: - # - name: ⬇️ Checkout repo - # uses: actions/checkout@v4 - - # - name: 🏄 Copy test env vars - # run: cp .env.example .env - - # - name: ⎔ Setup node - # uses: actions/setup-node@v3 - # with: - # cache: npm - # cache-dependency-path: ./package.json - # node-version: 18 - - # - name: 📥 Install deps - # run: npm install - - # - name: 🛠 Setup Database - # run: npx prisma migrate reset --force - - # - name: ⚙️ Build - # run: npm run build - - # - name: 🌳 Cypress run - # uses: cypress-io/github-action@v6 - # with: - # start: npm run start:mocks - # wait-on: http://localhost:8811 - # env: - # PORT: 8811 - deploy: name: 🚀 Deploy runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 582d11e..83f21b7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,6 @@ node_modules /public/build .env -/cypress/screenshots -/cypress/videos /prisma/data.db /prisma/data.db-journal diff --git a/README.md b/README.md index d989566..2c3cd2c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ npx create-remix@latest --template remix-run/indie-stack - Email/Password Authentication with [cookie-based sessions](https://remix.run/utils/sessions#md-createcookiesessionstorage) - Database ORM with [Prisma](https://prisma.io) - Styling with [Tailwind](https://tailwindcss.com/) -- End-to-end testing with [Cypress](https://cypress.io) - Local third party request mocking with [MSW](https://mswjs.io) - Unit testing with [Vitest](https://vitest.dev) and [Testing Library](https://testing-library.com) - Code formatting with [Prettier](https://prettier.io) @@ -141,31 +140,6 @@ We use GitHub Actions for continuous integration and deployment. Anything that g ## Testing -### Cypress - -We use Cypress for our End-to-End tests in this project. You'll find those in the `cypress` directory. As you make changes, add to an existing file or create a new file in the `cypress/e2e` directory to test your changes. - -We use [`@testing-library/cypress`](https://testing-library.com/cypress) for selecting elements on the page semantically. - -To run these tests in development, run `npm run test:e2e:dev` which will start the dev server for the app as well as the Cypress client. Make sure the database is running in docker as described above. - -We have a utility for testing authenticated features without having to go through the login flow: - -```ts -cy.login(); -// you are now logged in as a new user -``` - -We also have a utility to auto-delete the user at the end of your test. Just make sure to add this in each test file: - -```ts -afterEach(() => { - cy.cleanupUser(); -}); -``` - -That way, we can keep your local db clean and keep your tests isolated from one another. - ### Vitest For lower level tests of utilities and individual components, we use `vitest`. We have DOM-specific assertion helpers via [`@testing-library/jest-dom`](https://testing-library.com/jest-dom). diff --git a/cypress.config.ts b/cypress.config.ts deleted file mode 100644 index eaaf3ee..0000000 --- a/cypress.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { defineConfig } from "cypress"; - -export default defineConfig({ - e2e: { - setupNodeEvents: (on, config) => { - const isDev = config.watchForFileChanges; - const port = process.env.PORT ?? (isDev ? "3000" : "8811"); - const configOverrides: Partial = { - baseUrl: `http://localhost:${port}`, - video: !process.env.CI, - screenshotOnRunFailure: !process.env.CI, - }; - - // To use this: - // cy.task('log', whateverYouWantInTheTerminal) - on("task", { - log: (message) => { - console.log(message); - - return null; - }, - }); - - return { ...config, ...configOverrides }; - }, - }, -}); diff --git a/package.json b/package.json index 31814fa..8ac4829 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,6 @@ "start": "remix-serve ./build/index.js", "start:mocks": "binode --require ./mocks -- @remix-run/serve:remix-serve ./build/index.js", "test": "vitest", - "test:e2e:dev": "start-server-and-test dev http://localhost:3000 \"npx cypress open\"", - "pretest:e2e:run": "npm run build", - "test:e2e:run": "cross-env PORT=8811 start-server-and-test start:mocks http://localhost:8811 \"npx cypress run\"", "typecheck": "tsc", "validate": "run-p \"test -- --run\" lint typecheck test:e2e:run" }, diff --git a/remix.init/gitignore b/remix.init/gitignore index 38e2467..8336499 100644 --- a/remix.init/gitignore +++ b/remix.init/gitignore @@ -4,7 +4,5 @@ node_modules /public/build .env -/cypress/screenshots -/cypress/videos /prisma/data.db /prisma/data.db-journal diff --git a/remix.init/index.js b/remix.init/index.js index 97d6d53..4885361 100644 --- a/remix.init/index.js +++ b/remix.init/index.js @@ -7,16 +7,6 @@ const toml = require("@iarna/toml"); const PackageJson = require("@npmcli/package-json"); const semver = require("semver"); -const cleanupCypressFiles = ({ fileEntries, packageManager }) => - fileEntries.flatMap(([filePath, content]) => { - const newContent = content.replace( - new RegExp("npx ts-node", "g"), - `${packageManager.exec} ts-node`, - ); - - return [fs.writeFile(filePath, newContent)]; - }); - const escapeRegExp = (string) => // $& means the whole matched string string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); @@ -79,16 +69,6 @@ const main = async ({ packageManager, rootDirectory }) => { const EXAMPLE_ENV_PATH = path.join(rootDirectory, ".env.example"); const ENV_PATH = path.join(rootDirectory, ".env"); const DOCKERFILE_PATH = path.join(rootDirectory, "Dockerfile"); - const CYPRESS_SUPPORT_PATH = path.join(rootDirectory, "cypress", "support"); - const CYPRESS_COMMANDS_PATH = path.join(CYPRESS_SUPPORT_PATH, "commands.ts"); - const CREATE_USER_COMMAND_PATH = path.join( - CYPRESS_SUPPORT_PATH, - "create-user.ts", - ); - const DELETE_USER_COMMAND_PATH = path.join( - CYPRESS_SUPPORT_PATH, - "delete-user.ts", - ); const REPLACER = "indie-stack-template"; @@ -99,25 +79,15 @@ const main = async ({ packageManager, rootDirectory }) => { // get rid of anything that's not allowed in an app name .replace(/[^a-zA-Z0-9-_]/g, "-"); - const [ - prodContent, - readme, - env, - dockerfile, - cypressCommands, - createUserCommand, - deleteUserCommand, - packageJson, - ] = await Promise.all([ - fs.readFile(FLY_TOML_PATH, "utf-8"), - fs.readFile(README_PATH, "utf-8"), - fs.readFile(EXAMPLE_ENV_PATH, "utf-8"), - fs.readFile(DOCKERFILE_PATH, "utf-8"), - fs.readFile(CYPRESS_COMMANDS_PATH, "utf-8"), - fs.readFile(CREATE_USER_COMMAND_PATH, "utf-8"), - fs.readFile(DELETE_USER_COMMAND_PATH, "utf-8"), - PackageJson.load(rootDirectory), - ]); + const [prodContent, readme, env, dockerfile, packageJson] = await Promise.all( + [ + fs.readFile(FLY_TOML_PATH, "utf-8"), + fs.readFile(README_PATH, "utf-8"), + fs.readFile(EXAMPLE_ENV_PATH, "utf-8"), + fs.readFile(DOCKERFILE_PATH, "utf-8"), + PackageJson.load(rootDirectory), + ], + ); const newEnv = env.replace( /^SESSION_SECRET=.*$/m, @@ -156,14 +126,6 @@ const main = async ({ packageManager, rootDirectory }) => { fs.writeFile(README_PATH, newReadme), fs.writeFile(ENV_PATH, newEnv), fs.writeFile(DOCKERFILE_PATH, newDockerfile), - ...cleanupCypressFiles({ - fileEntries: [ - [CYPRESS_COMMANDS_PATH, cypressCommands], - [CREATE_USER_COMMAND_PATH, createUserCommand], - [DELETE_USER_COMMAND_PATH, deleteUserCommand], - ], - packageManager: pm, - }), packageJson.save(), fs.copyFile( path.join(rootDirectory, "remix.init", "gitignore"), diff --git a/tsconfig.json b/tsconfig.json index c0a761d..ac4ba36 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,4 @@ { - "exclude": ["./cypress", "./cypress.config.ts"], "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"], "compilerOptions": { "lib": ["DOM", "DOM.Iterable", "ES2020"],