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.

"No tests found" on docker with Jest v22 and v23

See original GitHub issue

💥 Regression Report

Running under Jest in a docker container is unable to find tests in v22 or v23, but can in v21. There are no problems running locally on OSX. Node version does not seem to be related.

Last working version

Version 21.2.1

Stopped working in version:

I believe version 22.0.0, but based on other jest dependencies installed (jest-cli, etc.) it’s hard to tell. Certainly in 22.4.4.

To Reproduce

Minimal set of files are in this repo: https://github.com/alistairjcbrown/jest-docker-issue With jest 21.2.1 in the package.json file, docker-compose run test which runs jest, finds files and passes. With jest 22.4.4 in the package.json file, docker-compose run test which runs jest, fails to find test files.

Expected behavior

With jest 22.4.4 (or above) in the package.json file, docker-compose run test should find test files and run them.

Link to repl or repo (highly encouraged)

Minimal repository: https://github.com/alistairjcbrown/jest-docker-issue

Run npx envinfo --preset jest

Paste the results here:

> $ docker-compose run test npx envinfo --preset jest
npx: installed 1 in 1.232s

  System:
    OS: Linux 4.9 Debian GNU/Linux 8 (jessie) 8 (jessie)
    CPU: x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
  Binaries:
    Node: 10.6.0 - /usr/local/bin/node
    Yarn: 1.7.0 - /usr/local/bin/yarn
    npm: 6.1.0 - /usr/local/bin/npm
  npmPackages:
    jest: 22.4.4 => 22.4.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
alistairjcbrowncommented, Jul 11, 2018

Looks like this can be worked around by creating a directory to copy files into and setting up a WORKDIR - maybe something in Jest v22 changed how it dealt with searching through top level files in a docker container? Using a work directory makes sense to me (though my docker knowledge is still fairly new).

I’ve created a branch off the minimal repository with the changes required to work and confirmed working with both latest v22 and v23. Branch diff: https://github.com/alistairjcbrown/jest-docker-issue/compare/use-work-directory

0reactions
github-actions[bot]commented, Apr 29, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest No Tests found - Stack Overflow
No tests found In /usr/src/app says that Jest is looking for tests in /usr/src/app , and testPathIgnorePatterns: /node_modules/,/src,src says ...
Read more >
Run your tests - Docker Documentation
There are unit tests, integration tests and end-to-end testing. In this guide we take a look at running your unit tests in Docker....
Read more >
Running Jest tests in a Docker container in an Azure Devops ...
The trick with running tests within a container is getting the test results out of the container and publishing them to the CI...
Read more >
Jest unit test works locally but fail on circleci docker image ...
I made sure that my circleci config.yml contains the right image version image: cimg/node:16.13; I sshd into the circleci container. The error I ......
Read more >
How to write tests for Prisma with Docker and Jest
We will need a Node container to run migrations and tests in. We do this in containers so the environment is consistent for...
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