Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update calls to Jest in all packages to avoid using PNPM .bin wrapper #43

Merged
merged 8 commits into from
Dec 13, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/flat-windows-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ilib-loctool-mrkdwn": patch
---

Added missing dependency on ilib.
7 changes: 7 additions & 0 deletions .changeset/nine-jobs-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"ilib-loctool-javascript": patch
"ilib-loctool-json": patch
"ilib-loctool-xml": patch
---

Added missing dependency on micromatch.
6 changes: 3 additions & 3 deletions packages/ilib-assemble/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
},
"scripts": {
"test": "pnpm test:cli",
"test:cli": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --testEnvironment node",
"test:watch": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --testEnvironment node --watch",
"debug": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --inspect-brk\" jest --testEnvironment node -i",
"test:cli": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js --testEnvironment node",
"test:watch": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js --testEnvironment node --watch",
"debug": "node --experimental-vm-modules --inspect-brk node_modules/jest/bin/jest.js --testEnvironment node -i",
"clean": "git clean -f -d src test ; rm -rf lib *.tgz",
"doc": "mkdir -p docs && jsdoc2md -c jsdoc.json --separators --source src/*.js -m table > docs/ilibAssemble.md && pnpm doc:html",
"doc:html": "jsdoc -c jsdoc.json"
Expand Down
5 changes: 2 additions & 3 deletions packages/ilib-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
"build:test": "webpack-cli --config webpack-test.config.js",
"build:pkg": "echo '{\"type\": \"commonjs\"}' > lib/package.json",
"test": "pnpm test:all",
"test:jest": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --testEnvironment node",
"test:jest": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js --testEnvironment node",
"test:karma": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" karma start --reporters dots",
"test:cli": "LANG=en_US.UTF8 pnpm build:dev && pnpm test:jest",
"test:web": "pnpm test:karma --single-run",
"test:watch": "pnpm test:jest --watch",
"test:all": "npm-run-all --npm-path pnpm test:cli test:web",
"debug": "pnpm build:dev; NODE_OPTIONS=\"$NODE_OPTIONS --inspect-brk\" jest --testEnvironment node -i",
"debug": "pnpm build:dev; node --inspect-brk node_modules/jest/bin/jest.js --testEnvironment node -i",
"debug:web": "pnpm test:karma",
"clean": "git clean -f -d src test; rm -rf lib",
"doc": "mkdir -p docs && jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilibCommon.md && pnpm doc:html",
Expand All @@ -88,7 +88,6 @@
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-uglify": "^5.2.2",
"jest": "^26.6.3",
"jest-mock": "^29.7.0",
"jsdoc": "^4.0.2",
"jsdoc-to-markdown": "^8.0.0",
"karma": "^6.4.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/ilib-data-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"build": "pnpm build:prod",
"build:prod": "grunt babel --mode=prod",
"build:dev": "grunt babel --mode=dev",
"test": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --testEnvironment node",
"test:watch": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --testEnvironment node --watch",
"debug": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --inspect-brk\" jest --testEnvironment node -i",
"test": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js --testEnvironment node",
"test:watch": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js --testEnvironment node --watch",
"debug": "node --experimental-vm-modules --inspect-brk node_modules/jest/bin/jest.js --testEnvironment node -i",
"clean": "git clean -f -d * ; rm -rf lib",
"doc": "mkdir -p docs && jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilib-data-utils.md && pnpm doc:html",
"doc:html": "jsdoc -c jsdoc.json"
Expand Down
4 changes: 2 additions & 2 deletions packages/ilib-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
"build:test": "webpack-cli --config webpack-test.config.js",
"build:pkg": "mkdir -p lib && echo '{\"type\": \"commonjs\"}' > lib/package.json",
"test": "pnpm run test:all",
"test:jest": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --testEnvironment node",
"test:jest": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js --testEnvironment node",
"test:karma": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" karma start --reporters dots",
"test:cli": "LANG=en_US.UTF8 npm-run-all --npm-path pnpm build:dev test:jest",
"test:web": "pnpm test:karma --single-run",
"test:watch": "pnpm test:jest --watch",
"test:all": "npm-run-all --npm-path pnpm test:cli test:web",
"debug": "pnpm build:dev && node --experimental-vm-modules --inspect-brk node_modules/.bin/jest --testEnvironment node -i",
"debug": "pnpm build:dev && node --experimental-vm-modules --inspect-brk node_modules/jest/bin/jest.js --testEnvironment node -i",
"debug:web": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/.bin/karma start --reporters dots",
"clean": "git clean -f -d src test; rm -rf lib",
"doc": "mkdir -p docs && jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilibEnv.md && pnpm doc:html",
Expand Down
8 changes: 5 additions & 3 deletions packages/ilib-lint-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@
"node": ">=14.0.0"
},
"scripts": {
"test": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"test:watch": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --watch",
"debug": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --inspect-brk\" jest -i",
"test": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test:watch": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
"debug": "LANG=en_US.UTF8 node --experimental-vm-modules --inspect-brk node_modules/jest/bin/jest.js -i",
"clean": "git clean -f -d src test",
"doc": "mkdir -p docs && jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilib-lint-common.md && pnpm run doc:html",
"doc:html": "jsdoc -c jsdoc.json",
"types": "tsc -p ./jsconfig.json"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@tsconfig/node14": "^14.1.0",
"@types/jest": "^29.5.14",
"@types/node": "^20.11.5",
"docdash": "^2.0.2",
"jest": "^29.7.0",
Expand Down
98 changes: 48 additions & 50 deletions packages/ilib-lint-common/test/SourceFile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
* limitations under the License.
*/

import fs from 'fs';
import SourceFile from '../src/SourceFile.js';
import jest from 'jest-mock';

import {describe, expect, test} from '@jest/globals';
import fs from "fs";
import SourceFile from "../src/SourceFile.js";
import { jest } from "@jest/globals";

/**
* @jest-environment node
Expand All @@ -37,39 +35,39 @@ const getLogger = (loggerName) => {
};
};

describe('SourceFile', () => {
const filePath1 = './test/testfiles/testfile1.txt';
const filePath2 = './test/testfiles/testfile2.txt';
const filePath3 = './test/testfiles/testfile3.txt';
const filePath4 = './test/testfiles/testfile4.txt';
describe("SourceFile", () => {
const filePath1 = "./test/testfiles/testfile1.txt";
const filePath2 = "./test/testfiles/testfile2.txt";
const filePath3 = "./test/testfiles/testfile3.txt";
const filePath4 = "./test/testfiles/testfile4.txt";

test('should throw an error if created without a file path', () => {
test("should throw an error if created without a file path", () => {
expect.assertions(1);

expect(() => new SourceFile(undefined)).toThrowError('Attempt to create a SourceFile without a file path');
expect(() => new SourceFile(undefined)).toThrowError("Attempt to create a SourceFile without a file path");
});

test('should create a SourceFile instance with the correct properties', () => {
test("should create a SourceFile instance with the correct properties", () => {
expect.assertions(2);

const sourceFile = new SourceFile(filePath1, { getLogger });
expect(sourceFile.getPath()).toBe(filePath1);
expect(sourceFile.getType()).toBe("string");
});

test('should create a SourceFile instance with provided options', () => {
test("should create a SourceFile instance with provided options", () => {
expect.assertions(2);

const customLogger = { log: jest.fn() };
const type = "test";
const sourceFile = new SourceFile(filePath1, {
type
type,
});
expect(sourceFile.getPath()).toBe(filePath1);
expect(sourceFile.getType()).toBe("test");
});

test('should read the raw file into memory correctly', () => {
test("should read the raw file into memory correctly", () => {
expect.assertions(2);

const sourceFile = new SourceFile(filePath1, { getLogger });
Expand All @@ -78,151 +76,151 @@ describe('SourceFile', () => {
expect(sourceFile.isDirty()).toBe(false);
});

test('should read the cooked file into memory correctly', () => {
test("should read the cooked file into memory correctly", () => {
expect.assertions(2);

const sourceFile = new SourceFile(filePath1, { getLogger });

expect(sourceFile.getContent()).toBe('Mock file content');
expect(sourceFile.getContent()).toBe("Mock file content");
expect(sourceFile.isDirty()).toBe(false);
});

test('should get the path to the source file', () => {
test("should get the path to the source file", () => {
expect.assertions(1);

const sourceFile = new SourceFile(filePath1, { getLogger });
expect(sourceFile.getPath()).toBe(filePath1);
});

test('should get the raw contents of the file as a Buffer', () => {
test("should get the raw contents of the file as a Buffer", () => {
expect.assertions(2);

const sourceFile = new SourceFile(filePath1, { getLogger });
const rawBuffer = sourceFile.getRaw();

expect(Buffer.isBuffer(rawBuffer)).toBe(true);
expect(rawBuffer?.toString('utf-8')).toBe('Mock file content');
expect(rawBuffer?.toString("utf-8")).toBe("Mock file content");
});

test('should get the content of the file as a string', () => {
test("should get the content of the file as a string", () => {
expect.assertions(1);

const sourceFile = new SourceFile(filePath1, { getLogger });
expect(sourceFile.getContent()).toBe('Mock file content');
expect(sourceFile.getContent()).toBe("Mock file content");
});

test('should get lines from the file content', () => {
test("should get lines from the file content", () => {
expect.assertions(3);

const sourceFile = new SourceFile(filePath2, { getLogger });
const lines = sourceFile.getLines();

expect(Array.isArray(lines)).toBe(true);
expect(lines).toHaveLength(3);
expect(lines).toEqual(['Line 1', 'Line 2', 'Line 3']);
expect(lines).toEqual(["Line 1", "Line 2", "Line 3"]);
});

test('should set lines to the file content', () => {
test("should set lines to the file content", () => {
expect.assertions(1);

const sourceFile = new SourceFile(filePath2, { getLogger });
const newLines = ['New Line 1', 'New Line 2', 'New Line 3'];
const newLines = ["New Line 1", "New Line 2", "New Line 3"];
const newSourceFile = new SourceFile(filePath2, {
file: sourceFile,
content: newLines.join('\n')
content: newLines.join("\n"),
});

expect(newSourceFile.getLines()).toEqual(newLines);
});

test('should not set lines to an empty array if null is provided', () => {
test("should not set lines to an empty array if null is provided", () => {
expect.assertions(1);

const sourceFile = new SourceFile(filePath2, { getLogger });
const newSourceFile = new SourceFile(filePath2, {
file: sourceFile,
content: null
content: null,
});

// The content of the file is still the same
expect(newSourceFile.getLines()).toEqual(['Line 1', 'Line 2', 'Line 3']);
expect(newSourceFile.getLines()).toEqual(["Line 1", "Line 2", "Line 3"]);
});

test('should not set lines to an empty array if undefined is provided', () => {
test("should not set lines to an empty array if undefined is provided", () => {
expect.assertions(1);

const sourceFile = new SourceFile(filePath2, { getLogger });
const newSourceFile = new SourceFile(filePath2, {
file: sourceFile,
content: undefined
content: undefined,
});

// The content of the file is still the same
expect(newSourceFile.getLines()).toEqual(['Line 1', 'Line 2', 'Line 3']);
expect(newSourceFile.getLines()).toEqual(["Line 1", "Line 2", "Line 3"]);
});

test('should handle empty lines in the file content', () => {
test("should handle empty lines in the file content", () => {
expect.assertions(1);

const sourceFile = new SourceFile(filePath3, { getLogger });

expect(sourceFile.getLines()).toEqual(['', '']);
expect(sourceFile.getLines()).toEqual(["", ""]);
});

test('should handle a single line in the file content', () => {
test("should handle a single line in the file content", () => {
expect.assertions(1);

const sourceFile = new SourceFile(filePath4, { getLogger });

expect(sourceFile.getLines()).toEqual(['Single Line']);
expect(sourceFile.getLines()).toEqual(["Single Line"]);
});

test('should set lines to an empty array if an empty array is provided', () => {
test("should set lines to an empty array if an empty array is provided", () => {
expect.assertions(2);

const sourceFile = new SourceFile(filePath2, { getLogger });

expect(sourceFile.getLines()).toEqual(['Line 1', 'Line 2', 'Line 3']);
expect(sourceFile.getLines()).toEqual(["Line 1", "Line 2", "Line 3"]);
const newSourceFile = new SourceFile(filePath2, {
file: sourceFile,
content: ''
content: "",
});
expect(newSourceFile.getLines()).toEqual(['']);
expect(newSourceFile.getLines()).toEqual([""]);
});

test('length is set correctly', () => {
test("length is set correctly", () => {
expect.assertions(1);

const sourceFile = new SourceFile(filePath2, { getLogger });

expect(sourceFile.getLength()).toBe(20);
});

test('length is updated after setLines', () => {
test("length is updated after setLines", () => {
expect.assertions(2);

const sourceFile = new SourceFile(filePath2, { getLogger });

expect(sourceFile.getLength()).toBe(20);
const newLines = ['New Line 1', 'New Line 2', 'New Line 3'];
const newLines = ["New Line 1", "New Line 2", "New Line 3"];
const newSourceFile = new SourceFile(filePath2, {
file: sourceFile,
content: newLines.join('\n')
content: newLines.join("\n"),
});
expect(newSourceFile.getLength()).toBe(32);
});

test('dirty flag is updated after setLines', () => {
test("dirty flag is updated after setLines", () => {
expect.assertions(2);

const sourceFile = new SourceFile(filePath2, { getLogger });

expect(sourceFile.isDirty()).toBeFalsy();
const newLines = ['New Line 1', 'New Line 2', 'New Line 3'];
const newLines = ["New Line 1", "New Line 2", "New Line 3"];
const newSourceFile = new SourceFile(filePath2, {
file: sourceFile,
content: newLines.join('\n')
content: newLines.join("\n"),
});
expect(newSourceFile.isDirty()).toBeTruthy();
});
});
});
4 changes: 2 additions & 2 deletions packages/ilib-lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
},
"scripts": {
"test": "pnpm test:jest",
"test:jest": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --trace-warnings --experimental-vm-modules\" jest",
"test:jest": "LANG=en_US.UTF8 node --trace-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
"test:watch": "pnpm test:jest --watch",
"debug": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --trace-warnings --experimental-vm-modules --inspect-brk\" jest -i",
"debug": "LANG=en_US.UTF8 node --experimental-vm-modules --inspect-brk node_modules/jest/bin/jest.js -i",
"lint": "node src/index.js",
"clean": "git clean -f -d src test",
"doc": "mkdir -p docs && jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilibLint.md && pnpm doc:html",
Expand Down
4 changes: 2 additions & 2 deletions packages/ilib-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"build:test": "webpack-cli --config webpack-test.config.js",
"build:pkg": "echo '{\"type\": \"commonjs\"}' > lib/package.json",
"test": "echo Success: TODO fix this to pnpm test:all",
"test:jest": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --testEnvironment node",
"test:jest": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/jest/bin/jest.js --testEnvironment node",
"test:karma": "LANG=en_US.UTF8 NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" karma start --reporters dots",
"test:cli": "LANG=en_US.UTF8 npm-run-all --npm-path pnpm build:dev test:jest",
"test:web": "pnpm test:karma --single-run",
"test:watch": "pnpm test:jest --watch",
"test:all": "npm-run-all --npm-path pnpm test:cli test:web",
"debug": "pnpm build:dev && node --experimental-vm-modules --inspect-brk node_modules/.bin/jest --testEnvironment node -i",
"debug": "pnpm build:dev && node --experimental-vm-modules --inspect-brk node_modules/jest/bin/jest.js --testEnvironment node -i",
"debug:web": "LANG=en_US.UTF8 node --experimental-vm-modules node_modules/.bin/karma start --reporters dots",
"clean": "git clean -f -d src test&& rm -rf lib",
"doc": "mkdir -p docs && jsdoc2md -c jsdoc.json --separators --source src/* -m table > docs/ilib-loader.md && pnpm doc:html",
Expand Down
6 changes: 3 additions & 3 deletions packages/ilib-loctool-android-layout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"url": "https://github.com/iLib-js/ilib-mono.git"
},
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"debug": "NODE_OPTIONS=\"$NODE_OPTIONS --inspect-brk\" jest -i",
"test": "node node_modules/jest/bin/jest.js",
"test:watch": "node node_modules/jest/bin/jest.js --watch",
"debug": "node --inspect-brk node_modules/jest/bin/jest.js -i",
"clean": "git clean -f -d *"
},
"engines": {
Expand Down
Loading
Loading