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

Move playwright to own directory and delete cypress #331

Merged
merged 14 commits into from
May 1, 2024
Merged
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
8 changes: 0 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,6 @@ module.exports = {
},
},

// Cypress
{
files: ["cypress/**/*.ts"],
plugins: ["cypress"],
extends: ["plugin:cypress/recommended", "prettier"],
rules: { "@typescript-eslint/no-namespace": "off" },
},

// Node
{
files: [".eslintrc.js", "mocks/**/*.js"],
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,19 @@ jobs:
run: npx prisma migrate reset --force

- name: create admin user
run: echo "ADMIN_COOKIE=$(npx ts-node --require tsconfig-paths/register ./cypress/support/create-user.ts 'test@example.com' ADMIN)" >> $GITHUB_ENV
run: echo "ADMIN_COOKIE=$(npx ts-node --require tsconfig-paths/register ./tasks/create-user.ts 'test@example.com' ADMIN)" >> $GITHUB_ENV

- name: Install Playwright
run: npx playwright install --with-deps
run: npm ci && npx playwright install --with-deps
working-directory: ./playwright
- name: Run Playwright tests
run: npx playwright test
working-directory: ./playwright
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
path: playwright/playwright-report/
retention-days: 30

sonarqube:
Expand Down Expand Up @@ -262,7 +264,7 @@ jobs:
pm2 save

# echo "*** Step: ** Run Playwright tests"
# echo "ADMIN_COOKIE=$(npx ts-node --require tsconfig-paths/register ./cypress/support/create-user.ts 'test@example.com' ADMIN)" >> .env
# echo "ADMIN_COOKIE=$(npx ts-node --require tsconfig-paths/register ./tasks/create-user.ts 'test@example.com' ADMIN)" >> .env
# npx playwright install --with-deps
# npx playwright test

Expand Down
16 changes: 3 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ coverage
/public/build
.env
Credentials.json
/cypress/screenshots
/cypress/videos
/prisma/data.db
/prisma/data.db-journal

Expand All @@ -15,16 +13,8 @@ Credentials.json
**/.DS_Store

# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/test-results/
/playwright-report/
/blob-report/
/playwright/test-results/
/playwirght/playwright-report/
/playwright/blob-report/
/playwright/.cache/
/playwright/.auth
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Based on the [The Remix Indie Stack](https://remix.run/stacks).
- [GitHub Actions](https://github.com/features/actions) for deploy on merge to production and staging environments
- Auth0 Authentication with [cookie-based sessions](https://remix.run/docs/en/v1/api/remix#createcookiesessionstorage)
- Database ORM with [Prisma](https://prisma.io)
- End-to-end testing with [Cypress](https://cypress.io)
- End-to-end testing with [Playwright](https://playwright.dev)
- 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 @@ -235,30 +235,31 @@ We use GitHub Actions for continuous integration and deployment. Anything that g

## Testing

### Cypress
### Playwright

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 Playwright for our End-to-End tests in this project. You'll find those in the `playwright` directory. As you make changes, add to an existing file or create a new file in the `playwright/tests` directory to test your changes.

We use [`@testing-library/cypress`](https://testing-library.com/cypress) for selecting elements on the page semantically.
Inside the playwright directory, you can run several commands:

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.
```sh
npx playwright test
# Runs the end-to-end tests.

We have a utility for testing authenticated features without having to go through the login flow:
npx playwright test --ui
# Starts the interactive UI mode.

```ts
cy.login();
// you are now logged in as a new user
```
npx playwright test --project=chromium
# Runs the tests only on Desktop Chrome.

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:
npx playwright test example
# Runs the tests in a specific file.

```ts
afterEach(() => {
cy.cleanupUser();
});
```
npx playwright test --debug
# Runs the tests in debug mode.

That way, we can keep your local db clean and keep your tests isolated from one another.
npx playwright codegen
# Auto generate tests with Codegen.
```

### Vitest

Expand Down
11 changes: 1 addition & 10 deletions app/routes/projects.$projectId.edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,12 @@ export default function EditProjectPage() {
useTypedLoaderData<typeof loader>();

const [open, setOpen] = useState(false);
const [isButtonDisabled, setisButtonDisabled] = useState(true);

const handleClickOpen = () => {
setOpen(true);

setTimeout(() => setisButtonDisabled(false), 5000);
};

const handleClose = () => {
setisButtonDisabled(true);
setOpen(false);
};

Expand Down Expand Up @@ -194,12 +190,7 @@ export default function EditProjectPage() {
<Button variant="contained" onClick={handleClose}>
Cancel
</Button>
<Button
variant="contained"
disabled={isButtonDisabled}
color="warning"
type="submit"
>
<Button variant="contained" color="warning" type="submit">
Yes, delete it
</Button>
</DialogActions>
Expand Down
39 changes: 0 additions & 39 deletions cypress.config.ts

This file was deleted.

6 changes: 0 additions & 6 deletions cypress/.eslintrc.js

This file was deleted.

28 changes: 0 additions & 28 deletions cypress/e2e/smoke.cy.ts

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

95 changes: 0 additions & 95 deletions cypress/support/commands.ts

This file was deleted.

17 changes: 0 additions & 17 deletions cypress/support/e2e.ts

This file was deleted.

36 changes: 0 additions & 36 deletions cypress/tsconfig.json

This file was deleted.

Loading
Loading