CodingGarden / listd

listd is a Full Stack App that will allow users to create, share and watch lists of YouTube channels. This app is being built LIVE on Twitch https://twitch.tv/codinggarden
https://twitch.tv/codinggarden
MIT License
193 stars 53 forks source link

test:e2e doesn't execute docker-down:test when playwright test is unsuccessful #122

Closed albertlast closed 1 year ago

albertlast commented 1 year ago

Describe the bug

When the test is not successfull, the docker-down:test script get not executed, which mean a rerun is not possible since the old docker instance a still running -> to shutedown manuell by execute the docker-down:test script by hand.

notice for the log: i run two commands two show the issue:

Screenshots

No response

Reproduction

i added a second button to the login page which create unsuccessful test in oauth.test.ts

Logs

PS F:\github\listd> npm run test:e2e        

> listd@0.0.1 test:e2e
> npm run docker-up:test && npm run migrate:init && cross-env NODE_ENV=test prisma db seed && playwright test && npm run docker-down:test

> listd@0.0.1 docker-up:test
> docker compose -f docker-compose.test.yml up -d --wait --force-recreate

[+] Running 3/3
 ✔ Network listd_default    Created                                                                                                                                                                                                                                                                               0.8s 
 ✔ Container listd-db-1     Healthy                                                                                                                                                                                                                                                                               3.6s 
 ✔ Container listd-redis-1  Healthy                                                                                                                                                                                                                                                                               3.6s 

> listd@0.0.1 migrate:init
> prisma migrate dev --name init

Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "listd", schema "public" at "localhost:5432"

Applying migration `20230331211353_init`

The following migration(s) have been applied:

migrations/
  └─ 20230331211353_init/
    └─ migration.sql

Your database is now in sync with your schema.

✔ Generated Prisma Client (4.14.0 | library) to .\node_modules\@prisma\client in 136ms
✔ Generated prisma-erd-generator-markdown (1.3.1) to .\prisma\ERD.md in 663ms

Environment variables loaded from .env
Running seed command `tsx ./prisma/seeds/index.ts` ...

The seed command has been executed.

Running 3 tests using 3 workers

[WebServer]
[WebServer]
[WebServer] ".prisma/client/index-browser" is imported by ".prisma/client/index-browser?commonjs-external", but could not be resolved – treating it as an external dependency.
[WebServer]
  ✓  1 app.test.ts:3:1 › index page has expected anchor tag (345ms)
  ✓  2 onboarding.test.ts:4:1 › new user redirects to the onboarding page (393ms)
  ✘  3 oauth.test.ts:3:1 › login button redirects to google (364ms)

  1) oauth.test.ts:3:1 › login button redirects to google ──────────────────────────────────────────

    Error: locator.click: Error: strict mode violation: getByRole('button') resolved to 2 elements:
        1) <button class="btn variant-filled-primary cursor-pointer">Login with YouTube</button> aka getByRole('button', { name: 'Login with YouTube' }).first()
        2) <button class="btn variant-filled-primary cursor-pointer">Login with YouTube</button> aka getByRole('button', { name: 'Login with YouTube' }).nth(1)

    =========================== logs ===========================
    ============================================================

      3 | test('login button redirects to google', async ({ page }) => {
      4 |       await page.goto('/');
    > 5 |       await page.getByRole('button').click();
        |                                      ^
      6 |       await page.waitForURL('**/accounts.google.com/**');
      7 |       expect(page.url()).toContain('https://accounts.google.com/');
      8 | });

        at F:\github\listd\tests\oauth.test.ts:5:33

  1 failed
    oauth.test.ts:3:1 › login button redirects to google ───────────────────────────────────────────
  2 passed (1.6s)
PS F:\github\listd> npm run docker-down:test

> listd@0.0.1 docker-down:test
> docker compose -f docker-compose.test.yml down

[+] Running 3/3
 ✔ Container listd-db-1     Removed                                                                                                                                                                                                                                                                               0.9s 
 ✔ Container listd-redis-1  Removed                                                                                                                                                                                                                                                                               0.6s 
 ✔ Network listd_default    Removed

Have you checked if this issue has already been raised?

Code of Conduct

w3cj commented 1 year ago

Thanks! Fixed in f31332e71bbe734a9fde7b6415f71e1d1e9f5314