Custom timezone for tests when running from intellij IDEA - intellij-plugin

I am trying to migrate tests from jest to vitest. For all of my tests I need to use UTC timezone. Currently, I was able to achieve it by TZ=UTC in package.json (refer: https://github.com/vitest-dev/vitest/issues/1575#issuecomment-1171085461).
"scripts": {
"dev": "vite",
"serve": "vite preview",
"build": "vite build",
"test": "TZ=UTC vitest run",
"test:watch": "TZ=UTC vitest"
}
My all the tests pass successfully when I am running the tests from CLI by using npm test. But when it comes to run tests from intellij looks like the tests aren't picking the timezone information from package.json. Is it expected behaviour?
I am using v0.6.6 of vitest runner and IntelliJ IDEA 2022.2.3.

You should specify this option in the JetBrains screen instead of package.json, as they are not using CLI as you.
https://blog.jetbrains.com/webstorm/2022/11/webstorm-2022-3-beta/

Related

How to deploy Vue.js app for production base on package-lock.json

I want to build a vue.js app for production with npm ci.
Should I put #vue/cli-service in devDependencies of my package.json and execute
npm ci
vue-cli-service --mode production
Or should I put #vue/cli-service in dependencies of my package.json and execute
npm ci --production
vue-cli-service --mode production
As indicated here:
"dependencies" : Packages required by your application in production.
"devDependencies" : Packages that are only needed for local development and testing.
If you look at how the vue cli bootstraps an application you'll see a minimal package.json look like:
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-service": "~4.5.0",
"#vue/compiler-sfc": "^3.0.0"
}
Depending on how you want to deploy your app, there are different ways. The one I usually use for my Vue projects is to have a two-fold deployment process:
build the app with vue-cli-service
deploy the app to whereever I want it to run
It is pretty handy to define a "deploy" script in your package.json once you have the deployment figured out, e.g.:
"scripts": {
"start": "npm run serve",
"build": "vue-cli-service build",
"deploy": "npm run build && ./deploy.sh",
},
"dependencies": {…
where your deploy.sh runs all the neccessary means for deployment. The Official Vue Documentation has further pointers towards deployment on many widely used platforms.
EDIT: I guess the answer to your question would be "You run npm run build with the build script as defined above". Because that is the way you build a Vue app for production. Further information: Documentation about Environment variables with vue-cli-service

What is needed to run "npm run build"?

What is needed to run npm run build?
I have project vue
I want to install it to a new server
Do I only need to run npm install?
Usually npm run build will create a production build.
The build process does a lot of things for you:
transpiles JS code
bundles code and assets
uses cache busting techniques for assets
removes dead code
Using the production build is the way to go for production.
Later edit:
You should install npm to be able to run npm commands. You should also run npm install before running npm run build.
you need package.json that contains :
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
}
and also must contains dependencies like this
"dependencies": {
"style-loader": "^1.1.4",
"vue": "^2.6.11",
"vuex": "^3.3.0"
},

Jest tests broken after implementing detox

I'd like to be able to run my detox tests and my Jest unit tests separately. For example, run detox tests with detox build && detox test, and my Jest unit tests with npm test.
After implementing detox (using mocha as the test runner), running npm test results in immediate error, and looks like its trying to run my detox tests (not what I'd expect)! Here's the first error I get.
FAIL e2e/auth.spec.js
Not sure why its trying to run detox tests, when my package.json is pointing the test script to Jest.
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
}
How do I run my jest tests now?
By default jest runs all files in your project directory, that have the .test. or .spec. extension to them. That's why it picks up your detox test files and fails to execute them.
https://facebook.github.io/jest/docs/en/configuration.html#testmatch-array-string
You have to override this default behavior in order for the two not to clash. Here's what we use in our package.json just for reference, you might want to change it:
"jest": {
"testMatch": [
"<rootDir>/__tests__/**/*.test.js?(x)",
"<rootDir>/src/**/*.test.js"
]
}
If you dont keep you files in on folder like tests just add this to package.json
"jest": {
"testMatch": ["**/*+(.test.js)"]
}

Can `npm test` run lint only?

After using npm test to do linting, it immediately starts to build all 2000 modules, and since it is already previously built, so I press CTRL-C, but only to find that because it got interrupted in the middle, some files are corrupted.
Is there a way to only run the linting without having it build all the modules?
Yes, your lint command is just something user made. If you go into your package.json and look for the 'test' command, you'll see that it calls several other commands including lint and build. Just make it lint only, or create a seperate function called npm lint. Here's an example package.json. As you can see, it has a lint and a test command.
{
"name": "boilerplate",
"version": "0.0.1",
"private": true,
"scripts": {
"start:native": "node node_modules/react-native/local-cli/cli.js start",
"start:web": "react-scripts start",
"lint": "eslint src/**",
"test": "node_modules/.bin/jest --env=jsdom",
"test:watch": "node_modules/.bin/jest --verbose --watchAll --env=jsdom"
}
}

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.