Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest testMatch finds tests, but testPathIgnorePatterns ignores them

I've been trying for a couple days to get Jest to run on an existing project. I'm using simple tests just to prove that I can run a test before I write anything more complex.

Here's the result when I run Jest:

No tests found
   In F:\+VS Project\path to project\
    348 files checked.
    testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 6 matches
    testPathIgnorePatterns: \\node_modules\\ - 348 matches
Pattern:  - 0 matches

System:

windows 10
Visual studio
ASP solution, with node project
webpack/babel for ES6

If I change testPathIgnorePatterns, it still seems to include the tests in the ignore patterns. When I add another test suite, both "testMatch" and "testPathIgnorePatterns" increase in # of matches by 1. I've tried wiping out the jest part of package.json, and I've tried adding lots of different things to package.json. The tests are in __test__ in the root of the project, and they do the following:

describe('can run a test', () => {
    // Define here the individual tests
        test('can run a test', () => {
            expect(true).toBe(true);
    });
})

This seems to happen regardless of whether I change any of the the input parameters. Am I supposed to export something from the test files? I've been looking around and around for a couple days trying to figure out why this is happening. I've seen several threads here that are related, but none of them really seem to describe my problem and solve it.

Please tell me I'm missing something dumb...

like image 413
Jefferson Avatar asked Nov 19 '17 19:11

Jefferson


1 Answers

As it turns out, the developers for Jest haven't sorted out their pathing issues yet. My Visual Studio projects were in a directory named "+VS Projects". Apparently the plus (and possibly the space as well) cause Jest to get confused and ignore everything in the directory.

It seems to not matter at all on my Linux machine.

A frustrating waste of a lot of good development time the past few months, all because Jest doesn't have good Windows support... OS snobbery kills again.

like image 157
Jefferson Avatar answered Nov 15 '22 08:11

Jefferson