开玩笑,在 GitLab 上找不到命令
Jest, command not found on GitLab
我想在 GITLAB 上使用 JEST 执行我的单元测试,但它似乎不起作用。
它适用于我的本地机器,但不适用于 GitLab。
.gitlab-ci.yml
的全部代码:
image: node:16
cache:
paths:
- node_modules
install:
stage: build
script: npm ci
jest:
stage: test
script: npm run test:ci
artifacts:
when: always
reports:
junit:
- junit.xml
Package.json
"test": "jest",
"test:ci": "jest --config ./jest.config.js --ci --reporters=default --reporters=jest-junit"
错误:
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-05-12T08_05_01_634Z-debug-0.log
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
我通过替换 Node 版本(我本地机器上的相同版本)发现了问题: image: node:14
.
安装需要一步,最好查看GitLab CI文档
image: node:16
cache:
paths:
- node_modules
install:
stage: build
script: npm ci
jest:
stage: test
script: npm run test:ci
artifacts:
when: always
reports:
junit:
- junit.xml
我想在 GITLAB 上使用 JEST 执行我的单元测试,但它似乎不起作用。
它适用于我的本地机器,但不适用于 GitLab。
.gitlab-ci.yml
的全部代码:
image: node:16
cache:
paths:
- node_modules
install:
stage: build
script: npm ci
jest:
stage: test
script: npm run test:ci
artifacts:
when: always
reports:
junit:
- junit.xml
Package.json
"test": "jest",
"test:ci": "jest --config ./jest.config.js --ci --reporters=default --reporters=jest-junit"
错误:
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-05-12T08_05_01_634Z-debug-0.log
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
我通过替换 Node 版本(我本地机器上的相同版本)发现了问题: image: node:14
.
安装需要一步,最好查看GitLab CI文档
image: node:16
cache:
paths:
- node_modules
install:
stage: build
script: npm ci
jest:
stage: test
script: npm run test:ci
artifacts:
when: always
reports:
junit:
- junit.xml