Skip to content

Commit

Permalink
remove cypress for good
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjirku committed Oct 15, 2023
1 parent 18918b8 commit 957a4c6
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 149 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ module.exports = {
},
},

// Cypress
{
files: ["cypress/**/*.ts"],
plugins: ["cypress"],
extends: ["plugin:cypress/recommended", "prettier"],
},

// Node
{
files: [".eslintrc.js", "mocks/**/*.js"],
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ node_modules
/public/build
.env

/cypress/screenshots
/cypress/videos
/prisma/data.db
/prisma/data.db-journal

Expand Down
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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).
Expand Down
27 changes: 0 additions & 27 deletions cypress.config.ts

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 0 additions & 2 deletions remix.init/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ node_modules
/public/build
.env

/cypress/screenshots
/cypress/videos
/prisma/data.db
/prisma/data.db-journal
56 changes: 9 additions & 47 deletions remix.init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, "\\$&");
Expand Down Expand Up @@ -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";

Expand All @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"exclude": ["./cypress", "./cypress.config.ts"],
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2020"],
Expand Down

0 comments on commit 957a4c6

Please sign in to comment.