我正在尝试运行测试,但总是收到错误消息
/Users/syafilm/Sites/Javascript/search-giphy-two/src/locales/en.yml:5
search-giphy: "Search Giphy here"
SyntaxError: Unexpected token :
1 | import i18next from 'i18next'
2 |
3 | const localeEn = require('locales/en.yml')
| ^
4 | const localeId = require('locales/id.yml')
5 |
6 | switch (document.documentElement.lang) {
npm运行测试,即使我只是像文档一样正确设置,也总是遇到相同的错误
module.exports = {
setupFiles: ["./jest.setup.js"],
verbose: true,
testRegex: "\\.test\(\.js|\.jsx)$",
moduleNameMapper: {
"^api(.*)$": "<rootDir>/src/api$1",
"^components(.*)$": "<rootDir>/src/components$1",
"^utils(.*)$": "<rootDir>/src/utils$1",
"^pages(.*)$": "<rootDir>/src/pages$1",
"^locales(.*)$": "<rootDir>/src/locales$1",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|yml)$": "<rootDir>/src/test/__mocks__/fileMock.js",
"^.+\\.(css|less|scss|yaml)$": "identity-obj-proxy",
},
transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"],
transform: {
".*\\.(yml)$": "yml",
}
}