Saturday, April 13, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  10] [ 1]  / answers: 1 / hits: 6638  / 4 Years ago, tue, november 3, 2020, 12:00:00

I run npm init npm i -D jest like in this tutorial


I am getting this error after running commend nmp test


This is not an error from creatures.js or creatures.test.js because without this file error happening. How can I fix this ? I tried already reinstating mode_modules. I don't know it have a matter but I'm using node 8.17.0 because I'm working with Firebase cloud functions


PS C:UsersPawelDesktopHerosIIIJS> npm test

> [email protected] test C:UsersPawelDesktopHerosIIIJS
> jest

C:UsersPawelDesktopHerosIIIJSnode_modulesjestnode_modulesjest-clibuildcliindex.js:227
} catch {
^

SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:UsersPawelDesktopHerosIIIJSnode_modulesjestnode_modulesjest-clibinjest.js:16:3)
npm ERR! Test failed. See above for more details.

const getProjectListFromCLIArgs = (argv, project) => {
const projects = argv.projects ? argv.projects : [];

if (project) {
projects.push(project);
}

if (!projects.length && process.platform === 'win32') {
try {
projects.push((0, _jestUtil().tryRealpath)(process.cwd()));
} catch { // <= error
// do nothing, just catch error
// process.binding('fs').realpath can throw, e.g. on mapped drives
}
}

if (!projects.length) {
projects.push(process.cwd());
}

return projects;
};

package.json


{
"name": "heros_iii_js",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
"devDependencies": {
"jest": "^26.6.2"
}
}


file structure:


![enter


More From » npm

 Answers
4

Upgrade node.js
In old version of node they were not handled the catch block of jest file.


It will work from node -v9.11.2 to so on.


[#2372] Thursday, October 29, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maxinec

Total Points: 117
Total Questions: 116
Total Answers: 116

Location: Bangladesh
Member since Sat, Jan 23, 2021
3 Years ago
maxinec questions
;