1
我有一個非常簡單的測試。帶'jest`的blueprintjs不起作用
在我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
你使用ts-jest嗎? –
是的,我正在使用'ts-jest' –