I just migrated to the newest version of WebdriverIO
Earlier was using:
"./node_modules/.bin/wdio wdio.conf.js /test/specs/ui.js" as command into package.json file
Now based on the offical docs can see:
"npx wdio wdio.conf.js /test/specs/ui.js"
Which is most official command in order to execute specific script?
I had a same issue. It's solved by this command. Before that check specs same as
specs: [
'./test/specs/**/*.js'
]
in wdio.conf.js`.
npx wdio --spec=yourfile.js
Related
I created a new Vue project via npm init vue#latest. I used the Vue CLI before and want to get into Vite now. Inside my Github action I used the Vue CLI service commands before but now I'm looking for the equivalent commands using Vite.
Check that the code style is fine (no errors, no warnings)
Inside my workflow I previously used the command
npm run lint -- --no-fix --max-warnings=0
Based on the lint script command
eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore
I added the lint:ci script command
eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --max-warnings 0 --ignore-path .gitignore
Check that unit tests are passing
Inside my workflow I previously used the command
npm run test:unit
Based on the test:unit script command
vitest --environment jsdom
I added the test:unit:ci script command
vitest --environment jsdom --run
Check that e2e tests are passing
Inside my workflow I previously used the command
npm run test:e2e -- --headless
There already is a test:e2e:ci script command and based on the Cypress docs I think I have to use it this way (which worked for me)
- name: Check if e2e tests are passing
uses: cypress-io/github-action#v2
with:
build: npm run build
start: npm run test:e2e:ci
Do you have any better solutions? I'm not sure if this is the most elegant way or if Vue/Vite already provide some commands I don't know about yet.
Thanks in advance!
I am using WebdriverIO.
I start my tests from the command line using 'npm test', which triggers the command: wdio wdio.conf.js as specified in my package.json here:
"scripts": {
"test": "wdio wdio.conf.js"
},
What I want to do is specify the actual test to run like this:
wdio wdio.conf.js --spec ./test/specs/e2e/login.js
My question is, how do I pass in the testcase from the npm command, i.e. how can I pass this --spec ./test/specs/e2e/login.js from the npm command into the wdio command?
You can do something like this.
npm run test -- --spec ./test/specs/e2e/login.js
Check this out. https://stackoverflow.com/a/14404223/3879644
I have run the command
yarn add -D jest to install jest to my project.
This does successfully add jest to my node_modules
> find . -name jest
./node_modules/.bin/jest
./node_modules/jest
When I use iterm2 to run jest however I get the following output
> jest
zsh: command not found: jest
FWIW When I use the IntelliJ terminal it does work
> jest
Determining test suites to run...^C
What am I missing in the iterm environment to be able to have node_modules bin in my classpath depending on the current repo?
An OS shell doesn't know about your locally installed node_modules, but IntelliJ terminal does. So if you want to run jest from outside of an IDE you should perform several additional steps.
The most common way to run locally installed packages is to define a separate script in the "scripts" section of your package.json file. Then you will be able to run it using the yarn/npm itself from any terminal. You can find an exact example in the Yarn docs.
{
"name": "my-package",
"scripts": {
"test": "jest"
}
}
yarn run test
Or you could install jest globally so it will be accessible from anywhere, but it's not a best practice.
I have installed cypress using npm as npm install cypress --save-dev .
I used the same command in .gitlab-ci.yml file
When i run the command npm run cypress run locally , IDE opens and when i double click the spec.js file , then the tests run.
But I i use the same command on the gitlab pipeline , it says
cypress open "run"
It looks like this is your first time using Cypress: 4.1.0
[07:45:16] Verifying Cypress can run /osmc/ux/framework-acceptance-tests/cache/Cypress/4.1.0/Cypress [started]
[07:45:18] Verifying Cypress can run /osmc/ux/framework-acceptance-tests/cache/Cypress/4.1.0/Cypress [completed]
Opening Cypress...
and build fails .
Am i missing anything here ?
It's because it's opening the test runner, which is used locally via npx cypress open.
From that output it looks like you're running npx cypress open run, which isn't a real command and will open the runner
In CI you need to use npx cypress run, which will run tests without user interaction. https://docs.cypress.io/guides/guides/command-line.html#How-to-run-commands
Your gitlab.yml file should accomodate for the npm installations.
One example is as below. Meanwhile also please check the test/run command for your specs under package.json file. use the same command to trigger the test in pipeline.
stages:
- test
test:
image: cypress/browsers:node12.14.1-chrome85
stage: test
script:
npm i
npm run start:ci &
npx cypress run
You should have your .gitlab-ci.yml with:
stages:
- test
cypress-test:
image: cypress/browsers:node16.14.0-slim-chrome99-ff97
stage: test
script:
- npm ci
- npx cypress run
I try to create my unit tests in my project with Jhipster 4.3 with Angular2.
But when i launch:
npm run test:watch
I have an error when i open http://localhost:9876/# and i can't debug my test:
Chrome 57.0.2987 (Windows 10 0.0.0) ERROR
You need to include some adapter that implements __karma__.start method!
I Have two questions:
Is it normal if i have this error with Jhipster default configuration?
How can I debug my test with Karma and the preprocessors with breackpoint in the chrome dev toolbar?
.
preprocessors: {'spec/entry.ts': ['webpack', 'sourcemap']}
Alternative solution **UPDATE:**
Actually, i launch the #angular-cli alternative:
ng test
But i can't correctly debug my test with breackpoint.
Thanks for your help!