bpierre/dnum

Problem with Jest

Closed this issue · 2 comments

I cannot make my unit tests work.

I get this error:

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

If I remove the lines of code that exploit dnum the tests work perfectly.

This is my jest.config.js:

module.exports = {
    preset: 'ts-jest',
    testEnvironment: 'node',
    roots: ["<rootDir>/src"],
    testMatch: ['**/*.test.(ts|tsx)'],
};

Could you please post a reproduction somewhere? Thanks 🙏

It seems to be an issue with ts-jest, that seems to expect CJS files: kulshekhar/ts-jest#937

Maybe you could try this? kulshekhar/ts-jest#937 (comment)

Closing the issue for now, but please reopen if you can provide a way for me to reproduce it.