Jest-expo test doesn't run - react-native

If I follow this readme:
https://github.com/expo/expo/tree/master/packages/jest-expo
My output when running npm run test is this:
> apprepo#0.0.0 test C:\Users\[username]\Documents\Projects\[projectname]
> jest
PS C:\Users\[username]\Documents\Projects\[projectname]>
It just outputs nothing. I tried with yarn as well, but no luck.

I had the same issue and fixed it by changing the "test" scripts section
from:
"test": "node_modules/.bin/jest"
to:
"test": "node ./node_modules/jest/bin/jest.js"
It seems their GitHub how-to is incorrect.

Related

Lint-staged aborts check with the first failing file; "Error: Unknown argument"

With "lint-staged": "^13.0.3" and the following .lintstagedrc config:
{
"src/**/*.{ts,html}": [
"ng lint"
],
"src/**/*.scss": [
"npx stylelint **/*.scss"
]
}
I'm trying to run npx lint-staged -q on the following files (all of them have lint problems that would come up with the individual lint command):
Running ng lint and npx stylelint **/*.scss directly will bring up the problems (detailed) and would not fail on the first file:
ng lint
npx stylelint **/*.scss
I'd like lint-staged's output to show all of the problems from the individual lint commands. What's wrong here?
Thanks
Ok, after further investigation;
The partial output problems seem to be introduced to lint-staged on versions >= 12.2.0, see on github. I've downgraded to "lint-staged": "12.1.7" and the problem seems to be gone.
Regarding the Unknown argument thing, it resolves by calling eslint instead of ng lint on the configuration file.

How to do npm scripts work vs direct commands?

I keep seeing this behavior, so I want to understand it. I install gulp and the gulp-cli (not globally). Typing the gulp command gives me -bash: gulp: command not found
I take the gulp command and drop it into an npm script and boom, it works. Can someone explain what's going on here?
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gulp": "gulp", // This works!!
"gulp-build": "gulp build" // As does this!!
},
Ahh, that makes sense. I was looking for the relative path to gulp in the project couldn't find the right path. Indeed ./node_modules/.bin/gulp does work. And thank you RobC for quoting that telling line in the docs. Totally makes sense now!

run npm script after package installing

I have a simple git repository https://github.com/alexey-sh/test_webpack_with_npm
I want to use it as npm dependency but without publishing in npm.
So in other words I want to install the package in my another repository as dependency.
npm i --save git+https://github.com/alexey-sh/test_webpack_with_npm.git
But I want to use a modern js in my test_webpack_with_npm project and compile it into old javascript after package installation process. To achieve it I created npm scripts (test_webpack_with_npm package)
"scripts": {
"install": "npm run build",
"build": "webpack --mode production --config webpack.config.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
so now there's a weird thing:
if I run npm run build from test_webpack_with_npm repository I can get dist/index.js without class declaration (as I expected).
but if I install the package via the following command
npm i --save git+https://github.com/alexey-sh/test_webpack_with_npm.git
I get another type of dist/index.js and there are class declaration.
How can I install the test_webpack_with_npm properly? I want to see old js in node_modules/test_webpack_with_npm/dist/index.js.
Steps to reproduce:
mkdir my_test_project
cd my_test_project
npm init
npm i --save git+https://github.com/alexey-sh/test_webpack_with_npm.git
check node_modules/test_webpack_with_npm/dist/index.js
Thanks!
the fix is very simple. just replace exclude with include in webpack config
include: path.join(__dirname, 'sources'),
that works perfectly.
updated config goes here https://github.com/alexey-sh/test_webpack_with_npm/blob/master/webpack.config.js

npm scripts not running in series

I want to run eslint as a prestart script so if it fails it won't run the build script, but even when the eslint returns "clean" result it still stops the following scripts from running.
So as you can see in the example below, the testing is not running.
I've even tried to replace the order and run the test first, but then the lint script doesn't run.
Any ideas?
"scripts": {
"prestart": "npm run lint:watch && npm run test:watch",
"start": "open:src",
"open:src": "nodemon --watch server --exec babel-node --debug=5858 --inspect server/srcServer.js --delay 2",
"lint": "node_modules/.bin/esw webpack.config.* --cache --max-warnings 0 src server",
"lint:watch": "npm run lint -- --watch",
"test": "mocha --reporter progress server/testSetup.js 'src/**/*.test.js'",
"test:watch": "npm run test -- --watch"
},
Now I know how it feels to be dumb :)
The "watch" in the test and lint caused it to stop since it doesn't exit.
Thank me very much for solving my issue.

Debugging nodejs run by babel-node with WebStorm

I have npm run script in package.json:
"scripts": {
"start": "nodemon lib/app.js --exec babel-node --presets es2015,stage-2"
}
How do you start a debugging session on WebStorm with this script?
Right-click on package.json in the Project view and select "Show npm Scripts":
This will display the npm Tool Window with a list of your scripts. Right-click on a script and select Debug 'start' (for example):
NPM Tool Window
For the debugger to work (so that it stops at breakpoints, etc.) you need to add the string $NODE_DEBUG_OPTION to the script definition, for example:
"scripts": {
blah: node $NODE_DEBUG_OPTION blah.js
}
It turns out the debug on WebStorm doesn't work with babel-node because babel-node does NOT output the transformed code. The issue tracker is here