Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testMatch error with Mapped Drive (Windows) #692

Closed
oxsd opened this issue Apr 20, 2020 · 3 comments
Closed

testMatch error with Mapped Drive (Windows) #692

oxsd opened this issue Apr 20, 2020 · 3 comments
Labels
scope: docs Documentation could be improved. Or changes that only affect docs scope: upstream Issue in upstream dependency

Comments

@oxsd
Copy link

oxsd commented Apr 20, 2020

Current Behavior

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

For example:

If:

  • Drive Z: is mapped to \\server\projects\
  • Project created at Z:\myproject

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
Copy link
Author

oxsd commented Apr 20, 2020

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
Copy link
Collaborator

agilgur5 commented Apr 21, 2020

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.

@agilgur5 agilgur5 added scope: docs Documentation could be improved. Or changes that only affect docs scope: upstream Issue in upstream dependency labels Apr 21, 2020
@oxsd
Copy link
Author

oxsd commented Apr 22, 2020

Thanks!

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

@oxsd oxsd closed this as completed Apr 22, 2020
@agilgur5 agilgur5 changed the title Test Match Error with Mapped Drive (Windows) testMatch error with Mapped Drive (Windows) Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: docs Documentation could be improved. Or changes that only affect docs scope: upstream Issue in upstream dependency
Projects
None yet
Development

No branches or pull requests

2 participants