Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ jobs:
with:
exclude: .github/,.storybook/

coverage:
name: Update test coverage
test:
name: Test on ${{ matrix.os }}
env:
CI: true
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [20.x]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
Expand All @@ -84,15 +84,22 @@ jobs:
shell: bash
run: pnpm install --frozen-lockfile

- name: Run tests
if: ${{ matrix.os != 'ubuntu-latest' }}
run: pnpm test --run

- name: Run tests with coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
run: pnpm coverage

- name: Upload coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build:
needs: [coverage, lint]
needs: [lint, test]
name: Build
env:
CI: true
Expand Down
9 changes: 8 additions & 1 deletion src/__tests__/discover-packages.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from "node:path";
import * as manypkg from "@manypkg/get-packages";
import {beforeEach, describe, expect, it, vi} from "vitest";
import {discoverPackages} from "../discover-packages";
Expand All @@ -8,6 +9,10 @@ vi.mock("@manypkg/get-packages", () => ({
getPackages: vi.fn(),
}));

function normalizePathForComparison(filePath: string): string {
return filePath.replaceAll(path.sep, "/");
}

describe("discoverPackages", () => {
beforeEach(() => {
vi.clearAllMocks();
Expand Down Expand Up @@ -77,7 +82,9 @@ describe("discoverPackages", () => {
const result = await discoverPackages(workspaceRoot);

// Assert
expect(result[0].path).toBe("/test/workspace/packages/test");
expect(normalizePathForComparison(result[0].path)).toBe(
"/test/workspace/packages/test",
);
});

it("should map package versions correctly", async () => {
Expand Down
9 changes: 8 additions & 1 deletion src/__tests__/find-matching-bins.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from "node:path";
import {beforeEach, describe, expect, it, vi} from "vitest";
import type {PackageInfo} from "../discover-packages";
import {findMatchingBins} from "../find-matching-bins";
Expand All @@ -9,6 +10,10 @@

import * as fs from "node:fs/promises";

function normalizePathForComparison(filePath: string): string {
return filePath.replaceAll(path.sep, "/");
}

describe("findMatchingBins", () => {
beforeEach(() => {
vi.clearAllMocks();
Expand Down Expand Up @@ -118,7 +123,9 @@
const matches = await findMatchingBins(packages, "x");

// Assert
expect(matches[0].binPath).toBe("/test/path/dist/x.mjs");
expect(normalizePathForComparison(matches[0].binPath)).toBe(

Check failure on line 126 in src/__tests__/find-matching-bins.test.ts

View workflow job for this annotation

GitHub Actions / Test on windows-latest

src/__tests__/find-matching-bins.test.ts > findMatchingBins > should include the bin path in the match

AssertionError: expected 'D:/test/path/dist/x.mjs' to be '/test/path/dist/x.mjs' // Object.is equality Expected: "/test/path/dist/x.mjs" Received: "D:/test/path/dist/x.mjs" ❯ src/__tests__/find-matching-bins.test.ts:126:64
"/test/path/dist/x.mjs",
);
});

it("should return empty array when no bins match", async () => {
Expand Down
Loading