When I run my jasmine test with Jest I get an error:
G:\git\diamant\SpaUI\node_modules\linqts\dist\src\index.js:10
export { default as List } from './list';
^^^^^^
SyntaxError: Unexpected token export
> 1 | import { List } from 'linqts';
| ^
2 | import { ReportMessageData } from './../models/report.model';
3 | import { TranslateService } from '@ngx-translate/core';
4 | import { Injectable } from '@angular/core';
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
at Object.<anonymous> (src/app/feature-modules/report/services/report-message-flatten.service.ts:1:1)
I understand that I have to tell Jest to transform the code to plain Javascript, but I don't know how to do it.
My jest.config.js looks as follows:
var preset = require("jest-preset-angular/jest-preset");
module.exports = {
...preset,
preset: "jest-preset-angular",
transformIgnorePatterns: ["<rootDir>/node_modules/(?!linqts)"],
testMatch: ["**/*.test.ts"],
globals: {
...preset.globals,
"ts-jest": {
...preset.globals["ts-jest"],
tsConfig: "src/tsconfig.test.json",
isolatedModules: true
}
},
moduleNameMapper: {
'^@diamant/feature-modules(.*)$': '<rootDir>/src/app/feature-modules/$1',
}
};