Skip to content

Commit f0ea2f3

Browse files
committed
ci: pin older jest in package.json before install
Rewrite the jest devDependency in package.json before `npm install` so npm resolves a consistent `@jest/*` transitive tree. Replacing jest via `npm install --no-save --force` after the main install left jest-cli's internal packages on v30, which crashes on Node <18.14.
1 parent 678ed7a commit f0ea2f3

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/nodejs.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,24 @@ jobs:
100100
architecture: ${{ steps.calculate_architecture.outputs.result }}
101101
cache: "npm"
102102

103+
- name: Pin older jest in package.json (Node 10/12)
104+
if: matrix.node-version == '10.x' || matrix.node-version == '12.x'
105+
shell: bash
106+
# Rewrite the jest devDependency before installing so npm resolves a
107+
# consistent @jest/* tree. jest@30 only supports Node >=18.14.
108+
run: |
109+
node -e "const fs=require('fs');const p=require('./package.json');p.devDependencies.jest='^27.5.1';fs.writeFileSync('./package.json',JSON.stringify(p,null,2)+'\n');"
110+
111+
- name: Pin older jest in package.json (Node 14/16)
112+
if: matrix.node-version == '14.x' || matrix.node-version == '16.x'
113+
shell: bash
114+
run: |
115+
node -e "const fs=require('fs');const p=require('./package.json');p.devDependencies.jest='^29.7.0';fs.writeFileSync('./package.json',JSON.stringify(p,null,2)+'\n');"
116+
103117
- name: Install dependencies (old)
104118
run: |
105119
npm install -D typescript@4 --force
106-
npm install --ignore-scripts
120+
npm install --ignore-scripts --force
107121
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x' || matrix.node-version == '18.x'
108122

109123
- name: Install dependencies
@@ -118,14 +132,6 @@ jobs:
118132
if: matrix.node-version == '14.x' || matrix.node-version == '16.x'
119133
run: npm install -D --no-save cssnano@^6 --force
120134

121-
- name: Install older jest (Node 10/12)
122-
if: matrix.node-version == '10.x' || matrix.node-version == '12.x'
123-
run: npm install -D --no-save jest@^27 --force
124-
125-
- name: Install older jest (Node 14/16)
126-
if: matrix.node-version == '14.x' || matrix.node-version == '16.x'
127-
run: npm install -D --no-save jest@^29 --force
128-
129135
- name: Install webpack ${{ matrix.webpack-version }}
130136
if: matrix.webpack-version != 'latest'
131137
run: npm i webpack@${{ matrix.webpack-version }}

0 commit comments

Comments
 (0)