Karma tests only run half the time in Docker environment
See original GitHub issueAre there any known race conditions that happen when Karma is used with Docker? The test runs correctly sometimes. Example: I run karma start and the tests don’t run correctly (shown below), but when I run it a second time, it might run correctly (also shown below).
Expected behaviour
The tests run consistently every time the karma server is started with ./node_modules/karma/bin/karma start ./karma.conf.ts
. I am in a Docker environment.
Actual behaviour
Sometimes, the tests run to completion correctly. Other times, the tests do not run at all.
When the tests run correctly:
When the tests don’t run correctly:
Environment Details
- Karma version (output of
karma --version
): 4.2.0 - Relevant part of your
karma.config.js
file
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Run Karma test in Docker - Stack Overflow
I am running this project in google cloud and it is working. Tests pass in the local environment and Karma is used.
Read more >Dockerizing an Angular App with Karma and Protractor ...
This tutorial shows how to Dockerize an Angular app, build with the Angular CLI, using Docker and Docker Compose for both development and ......
Read more >Six Ways to Build Docker Images Faster (Even in Seconds)
1. First, we need to delete images locally so that previous runs do not affect the test. docker rmi $(docker images -q) ·...
Read more >Run your tests - Docker Documentation
Now let's rebuild our image and run our tests. We will run the docker build command as above, but this time we will...
Read more >7 Github Actions Tricks I Wish I Knew Before I Started
Not only that, it will also trigger for any push to the branch that is initiating the pull request. This is a good...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@johnjbarton - make sense. I am definitely in CONFIGURING_DISCONNECTED state with this situation. I’ll see if I can work up that fix.
To be clear; in this case, it’s not calling browser_start at all in this situation without my proposed fix. I am actively testing that out though against a small test suite to be sure. Regardless, what you are saying as the proper fix makes sense.
Unfortunately the reporters are not designed to be resilient to reconnect. They may assume two browsers exist if the
browser_start
is sent twice. So we can’t sendbrowser_start
twice.I guess we need to introduce another state,
CONFIGURING_DISCONNECTED
to ensure thatEXECUTING_DISCONNECTED
always means that we did enterEXECUTING
before disconnect. In your scenario, your disconnect should be duringCONFIGURING_DISCONNECTED
and when you get to reconnect you can verify that state and emitbrowser_start
to enterEXECUTING
.Does that make sense?