我开始学习Jest测试框架,并尝试使用npm test
做简单的测试,但是我遇到了这个错误:
我正在尝试将import
更改为require
,但这没有帮助:(关于如何处理此错误的任何建议?
这也是我的package.json
文件部分,与
devDependencies and jest:
{
"devDependencies": {
"babel-core": "^6.26.3",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"jest": "^22.4.3",
"parcel-bundler": "^1.11.0"
},
"jest": {
"verbose": true,
"testURL": "http://localhost:1234/"
}
}
答案 0 :(得分:0)
1. Importing default export: Every module is said to have at most one default
export. In order to import the default export from a file, we can give a
name to the import making the syntax as the following.
import GIVEN_NAME from ADDRESS
2. Importing named values: Every module can have several named parameters and
in order to import one we should use the syntax as follows.
import { PARA_NAME } from ADDRESS
And similarly for multiple such imports we can use a comma to seperate two
parameter name within the curly braces.
3. Importing a combination of Default Exports and Named Values: The title
makes it clear what we need to see is that the syntax of the same. In order
to import a combination, we should use the following syntax.
import GIVEN_NAME, { PARA_NAME, ... } from ADDRESS