我有一个非常简单的测试。
在我package.json
看来是这样的
"jest": {
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"globals": {
"__TS_CONFIG__": "./tsconfig.json"
}
}
我的测试看起来像这样。
import * as React from "react";
import {} from "jest";
import { shallow } from "enzyme";
jest.unmock('classnames')
jest.unmock('../src/browser/browser');
import { Browser } from "../src/browser";
describe("Browser tests", function() {
test("test the browser loads", () => {
expect(3).toBe(3);
expect(shallow(<Browser />).contains(<div className="foo"
/>)).toBe(true);
});
});
我收到这个错误
/Users/..../node_modules/@blueprintjs/core/src/components/non-ideal-state/nonIdealState.tsx:8`
import * as classNames from "classnames";
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:290:17)
我做错了什么?任何帮助,将不胜感激
我在用
jest- 20.0.1
enzyme-2.8.2
ts-jest-20.0.3
blueprint-core 1.16.0