【发布时间】:2021-09-13 02:36:55
【问题描述】:
我正在尝试在 github 操作中为 lerna 维护的 monorepo 项目开玩笑。
name: Run Unit Test
on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
run: npm -v && npm install
- name: Run Unit Test
run: npm run test
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
在 github 操作中运行测试时出现jest: not found 错误。
你可以看到错误日志here。但是当我在自己的 macOS 中运行 npm install 和 npm run test 时,一切正常。
这是我的 root 的 package.json:
{
"private": true,
"description": "a progressive micro frontend library",
"workspaces": [
"packages/*"
],
"scripts": {
"postinstall": "lerna bootstrap",
"bootstrap": "lerna bootstrap",
"clean": "lerna clean",
"test": "lerna run test --stream",
"build": "lerna run build --stream",
"commit": "git cz",
"lint": "lerna run lint --stream",
"publish": "lerna publish",
"docs": "docsify serve docs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ObviousJs/obvious.git"
},
"author": "Philip Lau",
"license": "MIT",
"bugs": {
"url": "https://github.com/ObviousJs/obvious/issues"
},
"homepage": "https://github.com/ObviousJs/obvious#readme",
"publishConfig": {
"access": "public"
},
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
}
},
"devDependencies": {
"@rollup/plugin-commonjs": "20.0.0",
"@rollup/plugin-node-resolve": "13.0.4",
"@typescript-eslint/eslint-plugin": "4.31.0",
"@typescript-eslint/parser": "4.31.0",
"commitizen": "4.2.4",
"cz-conventional-changelog": "3.3.0",
"docsify-cli": "4.4.3",
"eslint": "7.32.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-import": "2.24.2",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.1.0",
"husky": "4.3.8",
"lerna": "4.0.0",
"rollup": "2.56.3",
"rollup-plugin-typescript2": "0.30.0"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint && npm run build && git add ./"
}
}
}
这是子项目的package.json:
{
"name": "@obvious/core",
"version": "0.4.0",
"description": "a progressive micro front framework",
"main": "./dist/index.umd.js",
"module": "./dist/index.es.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "rollup -c rollup.config.js",
"lint": "eslint --fix --ext .ts,.js test",
"test": "jest --coverage"
},
"author": "Philip Lau",
"license": "MIT",
"dependencies": {
"@vue/reactivity": "3.2.10",
"tslib": "2.3.1"
},
"devDependencies": {
"@types/jest": "27.0.1",
"jest": "27.1.1",
"nock": "13.1.3",
"node-fetch": "2.6.2",
"ts-jest": "27.0.5",
"typescript": "4.4.3"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ObviousJs/obvious-core.git"
},
"bugs": {
"url": "https://github.com/ObviousJs/obvious-core/issues"
},
"homepage": "https://github.com/ObviousJs/obvious-core#readme"
}
我的 github 仓库地址是https://github.com/ObviousJs/obvious-core。
对不起,我的泳池英语,但我真的需要一些帮助(orz
【问题讨论】:
-
没有节点你要如何运行 jest?
标签: jestjs github-actions lerna