k-g-a / jest-node-exports-resolver

MIT License
25 stars 7 forks source link

Fix handling absolute paths on Windows #15

Closed grpawel closed 2 years ago

grpawel commented 2 years ago

We have jest.config.js that looks somewhat like this:

module.exports = {
    rootDir: './',
    setupFiles: [
        '<rootDir>/scripts/someSetupFile.js',
    ],
    resolver: 'jest-node-exports-resolver',
}

On Windows the resolver is called with path like 'C:/pathToRepo/scripts/someSetupFile.js', which is causing an error:

Module \/scripts/someSetupFile.js in the setupFiles option was not found. \ is: C:\pathToRepo

An alternative fix would be to wrap everything in try and in catch return defaultResolver.

piranna commented 2 years ago

Thanks, merged :-)

grpawel commented 2 years ago

When could we expect the release in npm? :-)

piranna commented 2 years ago

Published as 1.1.6.