I cannot get tests in WebStorm to work for a React project I am working on.
I have the JavaScript language version set to React JSX, which means I have no compile errors.
Next I found a test example on the web and pasted it into a test file in my /test folder.
Magically some green arrows appear next to functions like describe and it. I click on one of these green arrows and run a test. Immediately I get this error :
/home/swe/Repositories/WebClient/code/tests/test2.js:21
<div>
^ SyntaxError: Unexpected token <
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
Why am I getting this error?
I am guessing that my compile JS is set to JSX, but whatever JavaScript is used by the test runner (I am thinking back to Java days) is using another JavaScript version.
I cannot find anything in the settings.
In fact I am not clear at all on how WebStorm uses testing. WebStorm recognises describe and it, which means, I am guessing, that WebStorm has Jasmine support.
In the settings I cannot find anything about Jasmine however. There is
something about 'Karma' in the plugins panel. I am guessing that this plugin also uses Jasmine.
Related
I added a firebase-admin in the NestJS Project, the unit test pass in the local code but fails in the CI/CD Pipeline.
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:
/opt/atlassian/pipelines/agent/build/node_modules/firebase-admin/lib/app/firebase-namespace.js:84
this.INTERNAL = new FirebaseNamespaceInternals(appStore ?? new lifecycle_1.AppStore());
^
SyntaxError: Unexpected token '?'
at compileFunction (<anonymous>)
at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1157:58)
at Object.<anonymous> (../node_modules/firebase-admin/lib/default-namespace.js:19:30)
at Object.<anonymous> (../node_modules/firebase-admin/lib/index.js:19:18)
All the tests passed locally from VS Code
I tried adding the testPathIgnorePatterns and other settings provided on the web. Didn't work.
The Nullish Coalescing Operator (??) was introduced to Node in version 14. Update your CI/CD pipeline to be a newer version of Node. The current version is 18 and I believe 12 is no longer LTS so upgrading is definitely something to look into.
Working on a project. Built a C++ module for node, compiled it with cmake. I tried using the module in my main electron app but it errors out.
Reproduced it with a minimal repo here: https://github.com/Aerrus/electronMinimal
App threw an error during load
Error: Module did not self-register.
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:160:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
at Module.load (internal/modules/cjs/loader.js:602:32)
at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
at Function.Module._load (internal/modules/cjs/loader.js:533:3)
at Module.require (internal/modules/cjs/loader.js:640:17)
at require (internal/modules/cjs/helpers.js:20:18)
at bindings (C:\Users\xxx\electronMinimal\mods\node_modules\bindings\bindings.js:112:48)
at Object.<anonymous> (C:\Users\xxx\electronMinimal\mods\index.js:1:188)
Saw a lot of threads already about rebuilding it, making sure the node version when I built it was the same, and so on. None of them changed anything.
If you're using electron v4.0
take a look at this. I hope it helped because that's how I solved the problem
adding delay hook to cmakelist using cmake-js
in the ionic app
trying to run ionic emulate ios but following error is coming
ionic-hello-world# ionic:build /Users/farrukhqamar/HybridApps/helloWorld
ionic-app-scripts build
keywords if/then/else require v5 option
/Users/farrukhqamar/HybridApps/helloWorld/node_modules/node-sass/lib/index.js:13
throw new Error(errors.unsupportedEnvironment());
^
Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (51)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v3.10.1
at Object. (/Users/farrukhqamar/HybridApps/helloWorld/node_modules/node-sass/lib/index.js:13:11)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/Users/farrukhqamar/HybridApps/helloWorld/node_modules/#ionic/app-scripts/dist/sass.js:11:19)
at Module._compile (module.js:571:32)
In the morning every thing was working but just start happening now in my current project
If i create a new project then it runs perfectly.
I am very new in ionic so please suggest some solution
Runtime (Node Module ABI) version 51 means it's an Electron environment, which node-sass doesn't directly support.
I setup a mocha "run configuration" for tests written in typescript and "run" command executes perfectly.
But when I choose to run a single test by click the "run ..." popup menu in the "run" window, syntax error occurs.
In the run window, WebStorm execute something like:
/usr/local/bin/node /(...)/node_modules/mocha/bin/_mocha --ui bdd --reporter /Applications/(...)/mochaIntellijReporter.js /(...)/my-test.ts --grep "MyTest Basic test$"
It seems that WebStorm passes .ts file instead of the generated .js file to mocha, and thus causes syntax errors.
Any ideas or workarounds?
As a workaround, .ts files can be run instead of the generated .js: specify --require ts-node/register in "Extra Mocha options" field (and npm install ts-node).
I am trying to write a C++ module for Node Js for a USB device. It is an accesio USB-IIRO-16 I/O board (accesio.com/MANUALS/USB-IIRO-16.PDF). I have the linux drivers installed along with libusb on Ubuntu 12.04 LTS. I have the sample apps (written in C++) running fine with the I/O board and am able to communicate with it just fine in C++. I'm new to writing nodejs modules, and haven't written C++ since college either. I have the module compiling fine as well. I am using the USBDeviceManager class provided by accesio which they use in their sample app.
I used this as a base for the module:
https://github.com/kkaefer/node-cpp-modules/tree/master/06_objects
I replaced the hpp file with the USBDeviceManager provided by accesio that is used in the sample app, and added ObjectWrap
class USBDeviceManager : public node::ObjectWrap {...}
The rest is the same as the USBDeviceManager along with the example module code. Everything compiles fine, however, when I run the node run.js I receive:
module.js:485
process.dlopen(filename, module.exports);
^
Error: /home/parallels/Documents/node-accesio/build/Release/accesio.node: undefined symbol: _ZTVN6AIOUSB16USBDeviceManagerE
at Object.Module._extensions..node (module.js:485:11)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/home/parallels/Documents/node-accesio/run.js:1:77)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
I've tried a lot of moving code around and some online documentation but can not figure out what to do at this point. The cpp and js files are still the same as the example module app right now (https://github.com/kkaefer/node-cpp-modules/tree/master/06_objects). the only thing that's different is adding the USBDeviceManager to the hpp file and the AIOUSB namespace.
Basically what I want to do, is to be able to read/write to the I/O board similar to the sample application found here:
http://accesio.com/files/packages/AIOUSB-Latest.tar.gz