Skip to content

Commit

Permalink
Node 22.12 + vitest + package bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao committed Jan 21, 2025
1 parent e3e3e47 commit d0c8f16
Show file tree
Hide file tree
Showing 15 changed files with 890 additions and 2,524 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # tag: v4.1.0
with:
node-version: 22.11.x
node-version: 22.12.x
- run: yarn --frozen-lockfile
- run: yarn build:docs
- name: Prepare docs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 22.11.x
node-version: 22.12.x
cache: 'yarn'
- name: Install
run: yarn install --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
node-version:
- 22.11.x
- 22.12.x
os:
- macos-latest
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.11
22.12
7 changes: 0 additions & 7 deletions jest.config.js

This file was deleted.

16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,42 @@
"prettier": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
"prettier:write": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"prepublishOnly": "npm run build",
"test": "jest --coverage",
"test": "vitest run --coverage",
"test:nonetwork": "npm run lint && npm run jest -- --testPathIgnorePatterns network.spec"
},
"files": [
"dist/",
"README.md"
],
"engines": {
"node": ">=22.0.0"
"node": ">=22.12.0"
},
"dependencies": {
"debug": "^4.1.1",
"env-paths": "^2.2.0",
"got": "^11.8.5",
"env-paths": "^3.0.0",
"got": "^14.4.5",
"progress": "^2.0.3",
"semver": "^7.6.3",
"sumchecker": "^3.0.1"
},
"devDependencies": {
"@tsconfig/node22": "^22.0.0",
"@types/debug": "^4.1.4",
"@types/jest": "^29.0.0",
"@types/node": "~22.10.5",
"@types/progress": "^2.0.3",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.0.0",
"@vitest/coverage-v8": "3.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.10.0",
"husky": "^9.1.7",
"jest": "^29.3.1",
"lint-staged": "^15.4.1",
"prettier": "^3.4.2",
"ts-jest": "^29.0.0",
"typedoc": "~0.25.13",
"typescript": "~5.4.5"
"typescript": "~5.4.5",
"vitest": "^3.0.3"
},
"husky": {
"hooks": {
Expand Down
2 changes: 2 additions & 0 deletions test/Cache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { Cache } from '../src/Cache';

describe('Cache', () => {
Expand Down
4 changes: 3 additions & 1 deletion test/GotDownloader.network.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import fs from 'node:fs';
import path from 'node:path';

import { describe, expect, it, vi } from 'vitest';

import { GotDownloader } from '../src/GotDownloader';
import { TempDirCleanUpMode, withTempDirectory } from '../src/utils';
import { EventEmitter } from 'events';
Expand Down Expand Up @@ -41,7 +43,7 @@ describe('GotDownloader', () => {

it('should throw an error if the file write stream fails', async () => {
const downloader = new GotDownloader();
const spy = jest.spyOn(fs, 'createWriteStream');
const spy = vi.spyOn(fs, 'createWriteStream');
spy.mockImplementationOnce(() => {
const emitter = new EventEmitter();
setTimeout(() => emitter.emit('error', 'bad write error thing'), 10);
Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/GotDownloader.network.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`GotDownloader download() should download a remote file to the given file path 1`] = `
exports[`GotDownloader > download() > should download a remote file to the given file path 1`] = `
"d186456c8e44155298521aafc5e270875c6cde41bbd3c19ce38ae53f1d98f284 *chromedriver-v2.0.18-darwin-x64.zip
dfb244c4347481a526567418f78a0fb6b9ccff6205a55f51225cfe4d1796b0d9 *chromedriver-v2.0.18-linux-arm.zip
516981ca6f7465dba55228df9ba30b7e0566a3eec694e5a2cc2fbe58a41ff006 *chromedriver-v2.0.18-linux-arm64.zip
Expand Down Expand Up @@ -58,7 +58,7 @@ f83f0433d0e2f4d62db59892d4105c5693242da867cb76f3ec42ce020868bf98 *mksnapshot-v2.
"
`;

exports[`GotDownloader download() should download to a deep uncreated path 1`] = `
exports[`GotDownloader > download() > should download to a deep uncreated path 1`] = `
"06fbdc5cdebf63b6fc579092d572878304125286b0db3ed0d6b1d506dc75e286 *chromedriver-v2.0.1-darwin-x64.zip
7347204e847fd7403dfac7de0a92a345932cc99a60b3279ca9e6d307483a190a *chromedriver-v2.0.1-linux-arm.zip
0a5807a4f26bc42de70d008e6ec775fed54a66f55d517b68071b801c3b306b4c *chromedriver-v2.0.1-linux-arm64.zip
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Public API download() should accept a custom downloader 1`] = `"https://github.com/electron/electron/releases/download/v2.0.3/electron-v2.0.3-platform-arch.zip"`;
exports[`Public API > download() > should accept a custom downloader 1`] = `"https://github.com/electron/electron/releases/download/v2.0.3/electron-v2.0.3-platform-arch.zip"`;
2 changes: 2 additions & 0 deletions test/artifact-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { getArtifactFileName, getArtifactRemoteURL } from '../src/artifact-utils';

describe('artifact-utils', () => {
Expand Down
2 changes: 2 additions & 0 deletions test/checksums.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { FixtureDownloader } from './FixtureDownloader';
import { downloadArtifact } from '../src';

Expand Down
8 changes: 5 additions & 3 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

import sumchecker from 'sumchecker';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { FixtureDownloader } from './FixtureDownloader';
import { download, downloadArtifact } from '../src';
import { DownloadOptions, ElectronDownloadCacheMode } from '../src/types';
import sumchecker from 'sumchecker';

jest.mock('sumchecker');
vi.mock('sumchecker');

describe('Public API', () => {
const downloader = new FixtureDownloader();
Expand Down Expand Up @@ -268,7 +270,7 @@ describe('Public API', () => {

describe('sumchecker', () => {
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});

it('should use the default constructor for versions from v1.3.5 onward', async () => {
Expand Down
57 changes: 18 additions & 39 deletions test/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import fs from 'node:fs';

import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';

import {
normalizeVersion,
uname,
Expand Down Expand Up @@ -79,55 +81,32 @@ describe('utils', () => {
});

describe('getHostArch()', () => {
let savedArch: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let savedVariables: any;

beforeEach(() => {
savedArch = process.arch;
savedVariables = process.config.variables;
});

afterEach(() => {
Object.defineProperty(process, 'arch', {
value: savedArch,
});
Object.defineProperty(process.config, 'variables', {
value: savedVariables,
});
});

it('should return process.arch on x64', () => {
Object.defineProperty(process, 'arch', {
value: 'x64',
});
vi.spyOn(process, 'arch', 'get').mockReturnValue('x64');
expect(getHostArch()).toEqual('x64');
});

it('should return process.arch on ia32', () => {
Object.defineProperty(process, 'arch', {
value: 'ia32',
});
vi.spyOn(process, 'arch', 'get').mockReturnValue('ia32');
expect(getHostArch()).toEqual('ia32');
});

it('should return process.arch on unknown arm', () => {
Object.defineProperty(process, 'arch', {
value: 'arm',
});
Object.defineProperty(process.config, 'variables', {
value: {},
vi.spyOn(process, 'arch', 'get').mockReturnValue('arm');
vi.spyOn(process, 'config', 'get').mockReturnValue({
...process.config,
variables: {} as any,
});
expect(getHostArch()).toEqual('armv7l');
});

if (process.platform !== 'win32') {
it('should return uname on arm 6', () => {
Object.defineProperty(process, 'arch', {
value: 'arm',
});
Object.defineProperty(process.config, 'variables', {
value: {
vi.spyOn(process, 'arch', 'get').mockReturnValue('arm');
vi.spyOn(process, 'config', 'get').mockReturnValue({
...process.config,
variables: {
//@ts-expect-error - `arm_version` actually exists
arm_version: '6',
},
});
Expand All @@ -136,11 +115,11 @@ describe('utils', () => {
}

it('should return armv7l on arm 7', () => {
Object.defineProperty(process, 'arch', {
value: 'arm',
});
Object.defineProperty(process.config, 'variables', {
value: {
vi.spyOn(process, 'arch', 'get').mockReturnValue('arm');
vi.spyOn(process, 'config', 'get').mockReturnValue({
...process.config,
variables: {
//@ts-expect-error - `arm_version` actually exists
arm_version: '7',
},
});
Expand Down
Loading

0 comments on commit d0c8f16

Please sign in to comment.