jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.26k stars 508 forks source link

testMatch error with Mapped Drive (Windows) #692

Closed oxsd closed 4 years ago

oxsd commented 4 years ago

Current Behavior

When using a mapped drive, the Test Match Pattern is incorrect.

For example:

If:

Test match ends up Z:/server/projects/myproject/**/*.(spec|test).{ts.tsx.js.jsx}.

Expected behavior

Test match should either be: //server/projects/myproject/**/*.(spec|test).{ts.tsx.js.jsx} or Z:/myproject/**/*.(spec|test).{ts.tsx.js.jsx}.

Your environment

Software Version(s)
TSDX 0.13.2
TypeScript 3.8.2
Browser N/A
npm/Yarn npm 6.4.1
Node 10.14.1
Operating System Windows
oxsd commented 4 years ago

FYI: Added the following to package.json:

"jest":   {
   "testMatch": [
      "Z:/myproject/**/*.(spec|test).{ts,tsx,js,jsx}"
   ]
}

The testMatch was then the value provided in package.json.

agilgur5 commented 4 years ago

Not sure that this a problem in TSDX or upstream. The built-in config's testMatch is pretty simple:

testMatch: ['<rootDir>/**/*.(spec|test).{ts,tsx,js,jsx}']

It's possible the mapped drive is causing problems with path resolution, but TSDX's path resolution is fairly simple too:

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
export const appDirectory = fs.realpathSync(process.cwd());
export const resolveApp = function(relativePath: string) {
  return path.resolve(appDirectory, relativePath);
};

resolveApp('.') is what is used as the rootDir.

If the path resolution were the problem however, that would cause issues in lots of other places. It's used all over, not just for tsdx test. So sounds more of an upstream issue but I'm not totally sure.


The testMatch was then the value provided in package.json.

Yes, you can use pacakge.json.jest or jest.config.js to further configure Jest; it'll be shallow-merged with TSDX's built-in config. This made me realize that his behavior is apparently not documented though o.o (it's existed for a pretty long time now), but it behaves the same as ESLint configs do with TSDX.

oxsd commented 4 years ago

Thanks!

Definately is an upstream issue with Jest since it's the only place the error came up and configging jest fixed it.