wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
759 stars 45 forks source link

Automatic Jest configuration error: Module jest-cli is not found in '.'. #2254

Closed sergey-kudriavtsev closed 4 years ago

sergey-kudriavtsev commented 5 years ago

Hi all! I can not understand the reason I am using mocha my wallaby.conf.js

module.exports = function (wallaby) {
  return {
    files: [
      'Services/Commons/core/*.js'
    ],

    tests: [
      'Services/Commons/test/**/*spec.js'
    ],
    testFramework: 'mocha',
    debug: true
  };
};

but at startup I get an answer Module jest-cli is not found in '/work/projects/prod

Wallaby Console: Failed to load configuration file: Automatic Jest configuration error: Module jest-cli is not found in '/work/projects/prod
(anonymous) @/home/dev/.atom/pack…ex.js:formatted:677
arrayEach   @/home/dev/.atom/pack…odash/index.js:1286
forEach         @/home/dev/.atom/pack…odash/index.js:5700
(anonymous) @/home/dev/.atom/pack…ex.js:formatted:676
emit            @events.js:182
(anonymous) @/home/dev/.atom/pack…nt.js:formatted:112
(anonymous) @/home/dev/.atom/pack…nt.js:formatted:311
emit            @events.js:182
addChunk    @_stream_readable.js:279
readableAddChunk@_stream_readable.js:260
Readable.push   @_stream_readable.js:219
onread          @net.js:636

Atom: 1.40.1 Electron: 3.1.10 Chrome:66.0.3359.181 Node:v10.2.0 Wallaby Console: Started Wallaby.js Core v1.0.766

mann-david commented 4 years ago

Did you ever get this resolved? I'm facing the same error.

smcenlly commented 4 years ago

UPDATE: Another reason why you may see the error (if you are using Jest) is that your Wallaby Core is not up-to-date (possibly because your license had expired) and you have updated your Jest version to v25. We have added the support for in Wallaby core version v1.0.822 (released end of Jan 2020), your current core version can be checked in Wallaby Console after Wallaby is started.

The error indicates that Wallaby is not using your configuration file and is instead using "automatic configuration". To run a configuration file, please select it in your editor. Steps to select a configuration file are described in our docs:

sergey-kudriavtsev commented 4 years ago

I understand why there was an error, I have a question why the configuration file is in the project, but the plugin does not raise it, but uses own by default.

See doc desdriptions

Wallaby.js for Atom needs to know what configuration file to use to run your tests. If you only have one file named wallaby.js/wallaby.conf.js in your project root, wallaby will automatically select it.

smcenlly commented 4 years ago

It looks like there's an edge case when you add a new wallaby configuration file to your project. Currently Wallaby is only looking for a configuration file when Atom first loads your project. We will update this behavior in the next release of Wallaby Atom.

Does that explain why the default behavior didn't work for you?

sergey-kudriavtsev commented 4 years ago

I think no. I tried to open the project (atom [/ my_path / ..]), it started right away from the project, the result is the same, only it manually sets. I assume that you are in the right direction, after installation, the start event for wallaby is not set, and wallaby does not respond.

ludwighogstrom commented 4 years ago

Hi! I had the same error with WebStorm / Jest and Automatic configuration type Failed to load configuration file: Automatic Jest configuration error: Module jest-cli is not found in....

When I updated the default nvm version (previous 8.x.x) to 12.x.x it started to work (nvm alias default 12.18.4).

maccurt commented 3 years ago

My issue was I was in a visual studio solution (in visual studio code) (c#) and I was not at the root of the Angular Project, if I opened visual studio code at the folder where my angular project was this error went away. Can I change some config to make this not happen?

smcenlly commented 3 years ago

@maccurt - you may try using the Wallaby.js: Select Configuration command and the Automatic Configuration <custom directory>... option. You will be prompted for your project location, select the folder that has your angular project.

maccurt commented 3 years ago

Thanks, that worked for me.

dht commented 1 year ago

From my experience using the "select configuration..." in a VSCode workspace fails to find the node_modules

smcenlly commented 1 year ago

@dht - if you are having problems, please create a new issue and provide your diagnostic report when you have the problem. Please also detail your project structure, it should help us identify why it's not working for you (and fix it, if it is a problem with Wallaby).

dht commented 1 year ago

The same issue as here. When I open a "workspace in VSCode" (same term, not related to Yarn/Npm workspaces) and I choose "Wallaby.js: Select Configuration" and I select a "wallaby.js" file which is not in the root of the workspace (again VSCode workspace, not Yarn/Npm) I get:

‌[Error] Automatic Jest configuration error: Module jest-cli is not found in '.'. 

If I open a new VSCode window with the same folder which consists of the "wallaby.js" and follow the same steps as described, everything works as expected. I deducted Wallaby must have some issues with VSCode workspaces.

Regarding opening a new issue, I think it is important to have this here as some people who will experience the error described in the title here are probably trying to run Wallaby in a VSCode Workspace setup.

smcenlly commented 1 year ago

If you are using a wallaby.js configuration file, the file must be in your project root for Wallaby to work.

dht commented 1 year ago

oh, Interesting to know... I've successfully used it differently for quite some time now. In a large mono-repo setup I create a wallaby.js for each package. It saves me the time of filtering the tests I want to run.

alecmce commented 1 year ago

I've just started seeing this issue again. I'm seeing a "Automatic Jest configuration error: Module jest-cli is not found in '.'" error when trying to run wallaby over a vitest project that has been working without problems until a recent update. (Yes, I will raise a new issue, just leaving this here as this is the first result on a Google search)

bj97301 commented 2 months ago

restarted vs code seemed to fix it for me. maybe some strange package ref somewhere with a node version... dunno