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

chore: add support to run tests in node 18.19 and node 20 #555

Merged
merged 3 commits into from
Oct 14, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18.18.2]
node-version: [18, 20]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
33 changes: 32 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@
"@types/semver": "^7.5.3",
"c8": "^10.1.2",
"cpy-cli": "^5.0.0",
"esmocha": "^1.0.1",
"esmocha": "^1.2.0",
"fs-extra": "^11.1.1",
"jsdoc": "^4.0.2",
"prettier": "3.0.3",
"prettier-plugin-packagejson": "^2.4.6",
"quibble": "^0.9.1",
"rimraf": "^5.0.5",
"sinon": "^19.0.2",
"sinon-test": "^3.1.5",
Expand Down
26 changes: 20 additions & 6 deletions test/generator-features.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import assert from 'node:assert';
import { Module } from 'node:module';
import sinon from 'sinon';
import { esmocha, expect, mock } from 'esmocha';
import { after, before, esmocha, expect } from 'esmocha';
import quibble from 'quibble';
import helpers, { getCreateEnv } from './helpers.js';
import { greaterThan5 } from './generator-versions.js';
import * as execaModule from 'execa';

const { commitSharedFsTask } = await mock('../src/commit.ts');
const { packageManagerInstallTask } = await mock('../src/package-manager.ts');
if (!Module.register) {
throw new Error('Node greater than v18.19.0 or v20.6.0 is required to test this module.');
}

const commitSharedFsTask = esmocha.fn();
const packageManagerInstallTask = esmocha.fn();
const execa = esmocha.fn();
await quibble.esm('../src/commit.ts', { commitSharedFsTask });
await quibble.esm('../src/package-manager.ts', { packageManagerInstallTask });
await quibble.esm('execa', { ...execaModule, execa });
const { default: BasicEnvironment } = await import('../src/environment-base.js');

for (const generatorVersion of greaterThan5) {
Expand All @@ -14,9 +25,12 @@ for (const generatorVersion of greaterThan5) {
class FeaturesGenerator extends Generator {}

describe(`environment (generator-features) using ${generatorVersion}`, () => {
beforeEach(() => {
afterEach(() => {
esmocha.resetAllMocks();
});
after(() => {
quibble.reset();
});

describe('customCommitTask feature', () => {
describe('without customInstallTask', () => {
Expand Down Expand Up @@ -172,8 +186,8 @@ for (const generatorVersion of greaterThan5) {
await runContext.run();
});

it('should not call packageManagerInstallTask', () => {
expect(packageManagerInstallTask).not.toHaveBeenCalled();
it('should not call execa', () => {
expect(execa).not.toHaveBeenCalled();
});
});

Expand Down
19 changes: 15 additions & 4 deletions test/package-manager.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { Module } from 'node:module';
import path, { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import sinon from 'sinon';
import { esmocha, expect, resetAllMocks } from 'esmocha';
import { esmocha, expect } from 'esmocha';
import quibble from 'quibble';

const { execa } = await esmocha.mock('execa');
const { whichPackageManager } = await esmocha.mock('which-package-manager');
if (!Module.register) {
throw new Error('Node greater than v18.19.0 or v20.6.0 is required to test this module.');
}

const execa = esmocha.fn();
await quibble.esm('execa', { execa });
const whichPackageManager = esmocha.fn();
await quibble.esm('which-package-manager', { whichPackageManager });

const { packageManagerInstallTask } = await import('../src/package-manager.js');

Expand Down Expand Up @@ -32,7 +40,10 @@ describe('environment (package-manager)', () => {
});

afterEach(() => {
resetAllMocks();
esmocha.resetAllMocks();
});
after(() => {
quibble.reset();
});

describe('#packageManagerInstallTask()', () => {
Expand Down
Loading