cookies
cookies copied to clipboard
Installation of this module breaks project tests
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/home/███/WebstormProjects/█████/node_modules/@nestjsplus/cookies/index.ts:1
export * from './dist';
^^^^^^
SyntaxError: Unexpected token 'export'
at compileFunction (<anonymous>)
39 | import { AuthService } from '../../auth/auth.service';
40 | import { AllowedRoles } from '../../auth/decorators/roles.decorator';
> 41 | import { Cookies } from '@nestjsplus/cookies';
| ^
42 | import { IpAddress } from '../../../utils/ip-address.decorator';
43 | import * as express from 'express';
44 |
at Runtime._execModule (../../../node_modules/@jest/core/node_modules/jest-runtime/build/index.js:988:58)
at Object.<anonymous> (../src/application/api/controllers/auth.controller.ts:41:1)
As a hotfix for those, who has same issue: just replace import to absolute, for example:
import { Cookies } from '@nestjsplus/cookies/dist/decorators/get-cookies.decorator';
@johnbiundo want me to take a look into fixing this? I think it's just a case of moving the index.ts intosrc and changing the files property of the package.json to properly point to dist.
@jmcdo29 Yes, please! Thanks very much!