GithubHelp home page GithubHelp logo

Comments (7)

zacharyweidenbach avatar zacharyweidenbach commented on May 11, 2024

Some more detail, if I test.skip on the 'I try to create a user with invalid data' test, I can make the test fail every time. This suggests that the tests fail intermittently when the 'I can create a user' runs first. And when I run the create-user.e2e-spec.ts in isolation, the test passes.

This leads me to believe there is some residual state from the delete-user.e2e-spec.ts test that causes this failure.

from domain-driven-hexagon.

Sairyss avatar Sairyss commented on May 11, 2024

I just tried it and tests worked fine for me. Here are the steps that I used:

  1. npm run docker:env - run docker
  2. create database ddh_tests - execute this SQL query to create a database for tests
  3. npm run migration:up:tests - execute migrations for test db
  4. npm run test:e2e - run tests

from domain-driven-hexagon.

zacharyweidenbach avatar zacharyweidenbach commented on May 11, 2024

That more or less matches what I did you setup the test suite.

It very much seems to matter what the test execution order is. The order that seems to reliably reproduced the issue, is:

  1. delete-user.e2e-spec.ts
  2. create-user.e2e-spec.ts - specifically with the I can create a user test running first. skipping the other test makes this easier to reproduce, because then it's just a matter of jest executing the delete-user test suite before the create-user test suite.

I've also added logging in the tests in order to query the entire contents of the user table in the db right before the I can create a user runs, and it shows the table as empty. This is more concerning, as now I suspect there is something wrong with the server-side code to unexpectedly encounter a user conflict on the john doe email address. I'll keep digging and report my findings back here.

from domain-driven-hexagon.

Sairyss avatar Sairyss commented on May 11, 2024

@zacharyweidenbach you are executing yarn test, you have to execute yarn test:e2e

from domain-driven-hexagon.

zacharyweidenbach avatar zacharyweidenbach commented on May 11, 2024

That seems to have resolved the failures. Even if I use jest's test-sequencer to coerce jest into running the delete-user test first, they both pass. Although that raises the question what's different between the .jestrc.json file and the jest-e2e.json that could explain why it was failing for yarn test and not yarn test:e2e. The only difference between them seems to be the coverageDirectory and the testRegex. I would expect to see different global setup files or something to understand what was missing from the yarn test config.

from domain-driven-hexagon.

zacharyweidenbach avatar zacharyweidenbach commented on May 11, 2024

Disregard, I see the test:e2e script uses -i which is the jest option --runInBand in order to serialize the tests on the current process.

from domain-driven-hexagon.

zacharyweidenbach avatar zacharyweidenbach commented on May 11, 2024

Closing, using the wrong test script

from domain-driven-hexagon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.