question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Karma tests only run half the time in Docker environment

See original GitHub issue

Are 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: image

When the tests don’t run correctly: image

Environment Details

  • Karma version (output of karma --version): 4.2.0
  • Relevant part of your karma.config.js file image

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
semaniocommented, May 20, 2020

@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.

1reaction
johnjbartoncommented, May 20, 2020

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 send browser_start twice.

I guess we need to introduce another state, CONFIGURING_DISCONNECTED to ensure that EXECUTING_DISCONNECTED always means that we did enter EXECUTING before disconnect. In your scenario, your disconnect should be during CONFIGURING_DISCONNECTED and when you get to reconnect you can verify that state and emit browser_start to enter EXECUTING.

Does that make sense?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found