Skip to content

Commit 4206d54

Browse files
authored
chore: update tests to work on windows (#35)
1 parent dbb12f8 commit 4206d54

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

Diff for: .github/workflows/autofix.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: autofix.ci # needed to securely identify the workflow
22

33
on:
44
pull_request:
5+
branches:
6+
- main
57

68
permissions:
79
contents: read

Diff for: .github/workflows/ci.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
- renovate/*
87
pull_request:
98
branches:
109
- main
@@ -28,7 +27,10 @@ jobs:
2827
run: pnpm lint
2928

3029
test:
31-
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
os: [ubuntu-latest, windows-latest]
33+
runs-on: ${{ matrix.os }}
3234
env:
3335
CI: true
3436

@@ -53,12 +55,14 @@ jobs:
5355
run: pnpm test
5456

5557
- name: Run benchmarks
58+
if: matrix.os != 'windows-latest'
5659
uses: CodSpeedHQ/action@v3
5760
with:
5861
run: pnpm vitest bench
5962
token: ${{ secrets.CODSPEED_TOKEN }}
6063

6164
- name: 🟩 Coverage
65+
if: matrix.os != 'windows-latest'
6266
uses: codecov/codecov-action@v4
6367
with:
6468
token: ${{ secrets.CODECOV_TOKEN }}

Diff for: .npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shell-emulator=true

Diff for: packages/beasties/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"dist"
4343
],
4444
"scripts": {
45-
"build": "unbuild && cp src/index.d.ts dist/index.d.ts",
46-
"build:stub": "unbuild --stub && cp src/index.d.ts dist/index.d.ts",
45+
"build": "unbuild && node -e \"require('fs/promises').cp('src/index.d.ts', 'dist/index.d.ts')\"",
46+
"build:stub": "unbuild --stub && node -e \"require('fs/promises').cp('src/index.d.ts', 'dist/index.d.ts')\"",
4747
"docs": "documentation readme src -q --no-markdown-toc -a public -s Usage --sort-order alpha",
4848
"prepack": "npm run -s build"
4949
},

Diff for: packages/beasties/test/beasties.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('beasties', () => {
4444
p.unused { color: orange; }
4545
`,
4646
}
47-
beasties.readFile = filename => assets[filename]!
47+
beasties.readFile = filename => assets[filename.replace(/^\w:/, '').replace(/\\/g, '/')]!
4848
const result = await beasties.process(trim`
4949
<html>
5050
<head>
@@ -98,7 +98,7 @@ describe('beasties', () => {
9898
h1 { color: blue; }
9999
`,
100100
}
101-
beasties.readFile = filename => assets[filename]!
101+
beasties.readFile = filename => assets[filename.replace(/^\w:/, '').replace(/\\/g, '/')]!
102102
const result = await beasties.process(trim`
103103
<html>
104104
<head>
@@ -126,7 +126,7 @@ describe('beasties', () => {
126126
h1 { color: blue; }
127127
`,
128128
}
129-
beasties.readFile = filename => assets[filename]!
129+
beasties.readFile = filename => assets[filename.replace(/^\w:/, '').replace(/\\/g, '/')]!
130130
const result = await beasties.process(trim`
131131
<html>
132132
<head>
@@ -156,7 +156,7 @@ describe('beasties', () => {
156156
h1 { color: blue; }
157157
`,
158158
}
159-
beasties.readFile = filename => assets[filename]!
159+
beasties.readFile = filename => assets[filename.replace(/^\w:/, '').replace(/\\/g, '/')]!
160160
const result = await beasties.process(trim`
161161
<html>
162162
<head>
@@ -188,7 +188,7 @@ describe('beasties', () => {
188188
p.unused { color: orange; }
189189
`,
190190
}
191-
beasties.readFile = filename => assets[filename]!
191+
beasties.readFile = filename => assets[filename.replace(/^\w:/, '').replace(/\\/g, '/')]!
192192
const result = await beasties.process(trim`
193193
<html>
194194
<body>
@@ -244,7 +244,7 @@ describe('beasties', () => {
244244
<body></body>
245245
</html>
246246
`)
247-
expect(beasties.readFile).toHaveBeenCalledWith('/var/www/file.css')
247+
expect(beasties.readFile).toHaveBeenCalledWith(path.resolve('/var/www/file.css'))
248248
expect(beasties.readFile).not.toHaveBeenCalledWith(
249249
'/company-secrets/secret.css',
250250
)

0 commit comments

Comments
 (0)