Skip to content

Commit b20e92f

Browse files
committed
Moved the shared parse-excel test helper back under packages/excel-parser/src/__tests__/helpers/parse-excel.ts and tightened packages/excel-parser/jest.config.ts so only real *.test.ts / *.spec.ts files under __tests__ are discovered by Jest. This keeps helpers colocated with tests without executing them as suites.
Also fixed temp workbook filename collisions in the shared helper by switching to randomUUID()-based filenames, which resolved intermittent failures in the full npm run test:unit --workspace=@supplier-config/excel-parser run.
1 parent 23d993b commit b20e92f

7 files changed

Lines changed: 10 additions & 12 deletions

packages/excel-parser/jest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const config: Config = {
1313
coverageDirectory: "./.reports/unit/coverage",
1414

1515
// Indicates which provider should be used to instrument code for coverage
16-
coverageProvider: "v8",
16+
coverageProvider: "babel",
1717

1818
coverageThreshold: {
1919
global: {
@@ -48,7 +48,7 @@ const config: Config = {
4848

4949
testEnvironment: "node",
5050
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
51-
testMatch: ["**/__tests__/**/*.ts", "**/?(*.)+(spec|test).ts"],
51+
testMatch: ["**/__tests__/**/*.test.ts", "**/__tests__/**/*.spec.ts"],
5252
moduleFileExtensions: ["ts", "js", "json", "node"],
5353

5454
transform: {

packages/excel-parser/src/test-helpers/parse-excel.ts renamed to packages/excel-parser/src/__tests__/helpers/parse-excel.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { randomUUID } from "node:crypto";
12
import * as XLSX from "xlsx";
23
import { tmpdir } from "node:os";
34
import path from "node:path";
45

5-
import { parseExcelFile } from "../parse-excel";
6+
import { parseExcelFile } from "../../parse-excel";
67

78
export interface WorkbookData {
89
packs?: Record<string, unknown>[];
@@ -180,7 +181,7 @@ export function buildWorkbookOmitting(omit: string): XLSX.WorkBook {
180181
}
181182

182183
export function writeWorkbook(workbook: XLSX.WorkBook): string {
183-
const filePath = path.join(tmpdir(), `test-${Date.now()}.xlsx`);
184+
const filePath = path.join(tmpdir(), `test-${randomUUID()}.xlsx`);
184185
XLSX.writeFile(workbook, filePath);
185186
return filePath;
186187
}

packages/excel-parser/src/__tests__/parse-excel.letter-variants.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
makePackRow,
33
makeVariantRow,
44
parseWorkbook,
5-
} from "../test-helpers/parse-excel";
5+
} from "./helpers/parse-excel";
66

77
describe("parse-excel letter variants", () => {
88
it("parses canonical enum values", () => {

packages/excel-parser/src/__tests__/parse-excel.pack-specifications.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
makePackRow,
33
makeVariantRow,
44
parseWorkbook,
5-
} from "../test-helpers/parse-excel";
5+
} from "./helpers/parse-excel";
66

77
describe("parse-excel pack specifications", () => {
88
it("throws on invalid postage size", () => {

packages/excel-parser/src/__tests__/parse-excel.suppliers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
makeSupplierRow,
66
makeVolumeGroupRow,
77
parseWorkbook,
8-
} from "../test-helpers/parse-excel";
8+
} from "./helpers/parse-excel";
99

1010
describe("parse-excel suppliers, allocations, and supplier packs", () => {
1111
it("parses Suppliers of all channel types", () => {

packages/excel-parser/src/__tests__/parse-excel.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { parseExcelFile } from "../parse-excel";
2-
import {
3-
buildWorkbookOmitting,
4-
writeWorkbook,
5-
} from "../test-helpers/parse-excel";
2+
import { buildWorkbookOmitting, writeWorkbook } from "./helpers/parse-excel";
63

74
describe("parse-excel workbook structure", () => {
85
it("throws when LetterVariant sheet is missing", () => {

packages/excel-parser/src/__tests__/parse-excel.volume-groups.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
makePackRow,
33
makeVariantRow,
44
parseWorkbook,
5-
} from "../test-helpers/parse-excel";
5+
} from "./helpers/parse-excel";
66

77
describe("parse-excel volume groups", () => {
88
it("parses VolumeGroup with description and endDate", () => {

0 commit comments

Comments
 (0)