Skip to content

Commit d8cbfcc

Browse files
committed
Run unit tests on Windows
This patch supersedes and closes #1291 [1]. [1] #1291
1 parent b33c26f commit d8cbfcc

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ jobs:
8989
run: npm install --engine-strict
9090
- name: Build
9191
run: npm run build
92-
- name: Test
92+
- name: Test (unit)
93+
run: npm run test:unit
94+
- name: Test (integration)
9395
run: npm run test:integration
9496
- name: Versions
9597
run: |

lib/helpers/posix.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import path from "node:path";
2+
3+
export const toPosix = (location: string) =>
4+
path.sep === "\\" ? location.replaceAll("\\", "/") : location;

lib/step-definitions.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
} from "./preprocessor-configuration";
99
import { getStepDefinitionPatterns, pathParts } from "./step-definitions";
1010

11+
import { toPosix } from "./helpers/posix";
12+
1113
const DUMMY_CONFIG: ICypressRuntimeConfiguration = {
1214
testingType: "e2e",
1315
projectRoot: "",
@@ -56,7 +58,7 @@ function example(
5658
}
5759

5860
for (let i = 0; i < expected.length; i++) {
59-
if (expected[i] !== actual[i]) {
61+
if (expected[i] !== toPosix(actual[i])) {
6062
throwUnequal();
6163
}
6264
}
@@ -70,7 +72,7 @@ describe("pathParts()", () => {
7072
it(`should return ${util.inspect(expectedParts)} for ${util.inspect(
7173
relativePath,
7274
)}`, () => {
73-
assert.deepEqual(pathParts(relativePath), expectedParts);
75+
assert.deepEqual(pathParts(relativePath).map(toPosix), expectedParts);
7476
});
7577
});
7678

lib/subpath-entrypoints/esbuild.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import { ensure } from "../helpers/assertions";
77
import { default as origDebug } from "../helpers/debug";
88
import { compile } from "../template";
99

10-
const debug = origDebug.extend("esbuild");
10+
import { toPosix } from "../helpers/posix";
1111

12-
const toPosix = (location: string) =>
13-
path.sep === "\\" ? location.replaceAll("\\", "/") : location;
12+
const debug = origDebug.extend("esbuild");
1413

1514
export function createEsbuildPlugin(
1615
configuration: Cypress.PluginConfigOptions,

0 commit comments

Comments
 (0)