#html #node.js #npm #frontend #webstorm
Вопрос:
У меня проблема с запуском простого проекта в среде IDE WebStorm. Вот что я получаю, когда нажимаю «Бежать»:
Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/home/patryk/WebstormProjects/Case Converter/node_modules/hs-test-web/hstest/stage/stageTest.js:12
runner = new PureJsApplicationRunner();
^
SyntaxError: Unexpected token =
at ScriptTransformer._transformAndBuildScript (node_modules/jest/node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (node_modules/hs-test-web/hstest/index.js:1:110)
На данный момент мой проект содержит всего 1 html-файл. Я попытался переустановить nodejs и npm, но это не сработало
Комментарии:
1. Пожалуйста, публикуйте текст, а не изображения текста.
Ответ №1:
Доброго времени суток, я столкнулся с той же проблемой с одним проектом Edu в среде IDE WebStorm — когда я нажал кнопку «проверить» для задачи — у меня возникла проблема: «набор тестов не удалось запустить, Jest столкнулся с неожиданным маркером …»
Как это было решено:
- Пожалуйста, проверьте, установлены ли nodejs и npm — В IDE: ФайлНастройки, раздел: Языки и фреймворки > раздел nodejs и npm >> в поле: «Интерпретатор узлов» вы найдете что-то вроде : «узел /usr/bin/узел», а в поле: «Менеджер пакетов» значение «npm /usr/общий доступ/npm»
- В IDE — вам нужно развернуть «Панель проекта» и выбрать режим просмотра «Файлы проекта» — затем вам нужно открыть файл «package.json», изначально этот файл содержит код:
{
"devDependencies": {
"@types/jest": "^23.3.12",
"hs-test-web": "https://github.com/hyperskill/hs-test-web/archive/release.tar.gz",
"jest": "^27.3.1",
"puppeteer": ">=8.0.0"
},
"scripts": {
"test": "jest"
}
}
Вам нужно добавить раздел «шутка» — пожалуйста, найдите полный пакет.json ниже
{
"devDependencies": {
"@types/jest": "^23.3.12",
"hs-test-web": "https://github.com/hyperskill/hs-test-web/archive/release.tar.gz",
"jest": "^27.3.1",
"puppeteer": ">=8.0.0"
},
"scripts": {
"test": "jest"
},
"jest": {
"verbose": true,
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"transform": {
"^. \.jsx?$": "babel-jest",
"^. \.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"transformIgnorePatterns": ["/node_modules/(?!lodash-es)"],
"testRegex": "test/.*\.spec\.ts$"
}
}
Так что я надеюсь,что это вам поможет.