qwikifiers / qwik-nx

Nx plugin for Qwik
131 stars 24 forks source link

feat(qwik-nx): add e2e project #40

Closed sebastiandg7 closed 1 year ago

sebastiandg7 commented 1 year ago

Fix #9

What is it?

Description

Add support to generate E2E testing projects for a qwik-nx generated qwik application. Following Qwik's default e2e testing approach, qwik-nx deafult's E2E test runner will also be playwright while providing the option to opt for cypress.

Added new application generator schema property:

name: e2eTestRunner type: enum values: playwright, cypress, none default value: playwright

Playwright is supported via @nxkit/playwright Cypress is supported via @nrwl/cypress

Use cases and why

nx g qwik-nx:app myapp
# or...
nx g qwik-nx:app myapp --e2eTestRunner playwright
nx g qwik-nx:app myapp --e2eTestRunner cypress
nx g qwik-nx:app myapp --e2eTestRunner none

Screenshots/Demo

Generated playwright and cypress projects:

image

Playwright tests result:

➜ npx nx e2e qwik-pw-e2e

> nx run qwik-pw-e2e:e2e

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose

Running 3 tests using 3 workers

  3 passed (5s)

To open last HTML report run:

  npx playwright show-report dist/apps/qwik-pw-e2e/playwright-report

Playwright tests ran for qwik-pw-e2e project

 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target e2e for project qwik-pw-e2e (6s)

Cypress tests result:

➜ npx nx e2e qwik-cy-e2e 

> nx run qwik-cy-e2e:e2e

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
====================================================================================================
  (Run Starting)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        12.3.0                                                                         │
  │ Browser:        Electron 106 (headless)                                                        │
  │ Node Version:   v18.13.0 (/Users/sduque/.volta/tools/image/node/18.13.0/bin/node)              │
  │ Specs:          1 found (app.cy.ts)                                                            │
  │ Searched:       src/**/*.cy.{js,jsx,ts,tsx}                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  app.cy.ts                                                                       (1 of 1)

  qwik-cy
    ✓ should display welcome message (565ms)
  1 passing (574ms)
  (Results)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     app.cy.ts                                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
  (Video)
  -  Started processing:  Compressing to 32 CRF                                                     
  -  Finished processing: /Users/sduque/dev/sebastiandg7/qwik-nx/tmp/nx-e2e/proj/dist    (0 seconds)
                          /cypress/apps/qwik-cy-e2e/videos/app.cy.ts.mp4                            
====================================================================================================
  (Run Finished)
       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  app.cy.ts                                572ms        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        572ms        1        1        -        -        -  

 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target e2e for project qwik-cy-e2e (6s)

Checklist:

shairez commented 1 year ago

Thanks @sebastiandg7 !

dmitry-stepanenko commented 1 year ago

@shairez please add @sebastiandg7 to contributors 🙂

shairez commented 1 year ago

@all-contributors please add @sebastiandg7 for code, ideas, tests

allcontributors[bot] commented 1 year ago

@shairez

I've put up a pull request to add @sebastiandg7! :tada: