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

test: refactor fast suite to use vitest #3797

Merged
merged 40 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2f066f8
i guess this works
erickzhao Nov 30, 2024
f3dd453
remove resolution
erickzhao Dec 18, 2024
40e263a
checkpoint
erickzhao Dec 18, 2024
9af6daf
clean up :)
erickzhao Dec 18, 2024
5fd4661
forgot to push up lockfile
erickzhao Dec 20, 2024
2b86202
resolveDir spec
erickzhao Dec 20, 2024
906d59d
upgrade-forge-config tests
erickzhao Dec 20, 2024
1932774
convert start tests + cleanup
erickzhao Dec 23, 2024
8dc93bd
install-dependencies
erickzhao Jan 2, 2025
b19b131
delete superseded tests
erickzhao Jan 2, 2025
bb323ac
appx tests
erickzhao Jan 2, 2025
6701453
makerbase tests
erickzhao Jan 3, 2025
ebcf814
makerdeb test
erickzhao Jan 3, 2025
bc5d578
makerdmg tests
erickzhao Jan 3, 2025
d51c89b
flatpak and pkg
erickzhao Jan 3, 2025
15a8ca1
rpm tests
erickzhao Jan 6, 2025
0a9bd3b
maker snap
erickzhao Jan 6, 2025
80a3923
wix
erickzhao Jan 6, 2025
42adb6b
maker-zip tests
erickzhao Jan 6, 2025
37becf2
local electron plugin
erickzhao Jan 6, 2025
1d0c4cf
webpack plugin tests
erickzhao Jan 7, 2025
e40fb82
vite tests
erickzhao Jan 7, 2025
c92c316
MSW a few publishers
erickzhao Jan 8, 2025
8ec5baf
publisher github
erickzhao Jan 9, 2025
8c202fd
finish up tests
erickzhao Jan 9, 2025
fcabab3
remove packages
erickzhao Jan 9, 2025
bfe1996
generalize assertion for publish test
erickzhao Jan 9, 2025
327e039
increase test timeout
erickzhao Jan 9, 2025
69882d2
use junit reporter in CI
erickzhao Jan 9, 2025
d9ec6c7
Merge branch 'main' into modern-tests
erickzhao Jan 9, 2025
a83a571
turn down parallelism?
erickzhao Jan 9, 2025
d3ae2e3
fixes :)
erickzhao Jan 9, 2025
f2b1e5b
add xvfb-maybe
erickzhao Jan 9, 2025
f8c0cba
increase timeout again on npm install in asset relocator patch test
erickzhao Jan 9, 2025
0969c3f
debug statement
erickzhao Jan 9, 2025
23f79ec
does this fix it?
erickzhao Jan 9, 2025
1e7af04
fully migrate to jest-like matchers
erickzhao Jan 9, 2025
4e1bdd7
make timeout longer
erickzhao Jan 9, 2025
4618257
increase test timeout again
erickzhao Jan 9, 2025
ed5aa8f
Merge branch 'main' into modern-tests
erickzhao Jan 10, 2025
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
Prev Previous commit
Next Next commit
makerbase tests
  • Loading branch information
erickzhao committed Jan 3, 2025
commit 6701453e815422119aaaf5f03599cb4c61767fce
3 changes: 2 additions & 1 deletion packages/maker/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"devDependencies": {
"chai": "^4.3.3",
"mocha": "^9.0.1",
"sinon": "^13.0.1"
"sinon": "^13.0.1",
"vitest": "^2.1.6"
},
"engines": {
"node": ">= 16.4.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,39 @@
import { expect } from 'chai';
import { stub } from 'sinon';
import { describe, expect, it, vi } from 'vitest';

import { MakerBase } from '../src/Maker';

class MakerImpl extends MakerBase<{ a: number }> {
name = 'test';

defaultPlatforms = [];
}

describe('prepareConfig', () => {
it('should accept sync configure functions', async () => {
const fetcher = stub();
fetcher.returns({
const fetcher = vi.fn();
fetcher.mockReturnValue({
a: 123,
});
const maker = new MakerImpl(fetcher, []);
expect(maker.config).to.be.undefined;
expect(fetcher.callCount).to.equal(0);
await maker.prepareConfig('x64');
expect(maker.config).to.deep.equal({
expect(maker.config).toEqual({
a: 123,
});
expect(fetcher.callCount).to.equal(1);
expect(fetcher.firstCall.args).to.deep.equal(['x64']);
expect(fetcher).toHaveBeenCalledOnce();
expect(fetcher).toHaveBeenCalledWith('x64');
});

it('should accept async configure functions', async () => {
const fetcher = stub();
fetcher.resolves({
const fetcher = vi.fn();
fetcher.mockResolvedValue({
a: 123,
});
const maker = new MakerImpl(fetcher, []);
expect(maker.config).to.be.undefined;
expect(fetcher.callCount).to.equal(0);
await maker.prepareConfig('x64');
expect(maker.config).to.deep.equal({
expect(maker.config).toEqual({
a: 123,
});
expect(fetcher.callCount).to.equal(1);
expect(fetcher.firstCall.args).to.deep.equal(['x64']);
expect(fetcher).toHaveBeenCalledOnce();
expect(fetcher).toHaveBeenCalledWith('x64');
});

it('should hand through the provided object', async () => {
Expand All @@ -49,9 +43,9 @@ describe('prepareConfig', () => {
},
[]
);
expect(maker.config).to.be.undefined;
expect(maker.config).toBeUndefined();
await maker.prepareConfig('x64');
expect(maker.config).to.deep.equal({
expect(maker.config).toEqual({
a: 234,
});
});
Expand Down
66 changes: 66 additions & 0 deletions packages/maker/base/spec/ensure-output.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

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

import { EmptyConfig, MakerBase } from '../src/Maker';

class MakerImpl extends MakerBase<EmptyConfig> {
name = 'test';

defaultPlatforms = [];
}

const maker = new MakerImpl({}, []);
let tmpDir: string;

describe('ensure-output', () => {
beforeEach(async () => {
const tmp = os.tmpdir();
const tmpdir = path.join(tmp, 'electron-forge-test-');
tmpDir = await fs.promises.mkdtemp(tmpdir);
});

afterEach(async () => {
await fs.promises.rm(tmpDir, { recursive: true });
});

describe('ensureDirectory', () => {
it('should delete the directory contents if it exists', async () => {
fs.mkdirSync(path.resolve(tmpDir, 'foo'));
fs.writeFileSync(path.resolve(tmpDir, 'foo', 'touchedFile'), '');
expect(fs.existsSync(path.resolve(tmpDir, 'foo', 'touchedFile'))).toEqual(true);

await maker.ensureDirectory(path.resolve(tmpDir, 'foo'));

expect(fs.existsSync(path.resolve(tmpDir, 'foo', 'touchedFile'))).toEqual(false);
});

it('should create the directory if it does not exist', async () => {
expect(fs.existsSync(path.resolve(tmpDir, 'bar'))).toEqual(false);
await maker.ensureDirectory(path.resolve(tmpDir, 'bar'));
expect(fs.existsSync(path.resolve(tmpDir, 'bar'))).toEqual(true);
});
});

describe('ensureFile', () => {
it('should delete the file if it exists', async () => {
fs.mkdirSync(path.resolve(tmpDir, 'foo'));
fs.writeFileSync(path.resolve(tmpDir, 'foo', 'touchedFile'), '');
expect(fs.existsSync(path.resolve(tmpDir, 'foo', 'touchedFile'))).toEqual(true);

await maker.ensureFile(path.resolve(tmpDir, 'foo'));

expect(fs.existsSync(path.resolve(tmpDir, 'foo', 'touchedFile'))).toEqual(false);
});

it('should create the containing directory if it does not exist', async () => {
expect(fs.existsSync(path.resolve(tmpDir, 'bar'))).toEqual(false);

await maker.ensureFile(path.resolve(tmpDir, 'bar', 'file'));

expect(fs.existsSync(path.resolve(tmpDir, 'bar'))).toEqual(true);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from 'chai';
import { describe, expect, it } from 'vitest';

import { EmptyConfig, MakerBase } from '../src/Maker';

Expand All @@ -14,6 +14,6 @@ describe('ensureExternalBinariesExist', () => {
const maker = new MakerImpl({}, []);

it('throws an error when one of the binaries does not exist', () => {
expect(() => maker.ensureExternalBinariesExist()).to.throw(/the following external binaries need to be installed: bash, nonexistent/);
expect(() => maker.ensureExternalBinariesExist()).toThrow(/the following external binaries need to be installed: bash, nonexistent/);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from 'chai';
import { describe, expect, it } from 'vitest';

import { EmptyConfig, MakerBase } from '../src/Maker';

Expand All @@ -13,15 +13,15 @@ describe('normalizeWindowsVersion', () => {

it('removes everything after the dash', () => {
for (const version of ['1.0.0-alpha', '1.0.0-alpha.1', '1.0.0-0.3.7', '1.0.0-x.7.z.92']) {
expect(maker.normalizeWindowsVersion(version)).to.equal('1.0.0.0');
expect(maker.normalizeWindowsVersion(version)).toEqual('1.0.0.0');
}
});
it('removes everything after the plus sign', () => {
for (const version of ['1.0.0-alpha+001', '1.0.0+20130313144700', '1.0.0-beta+exp.sha.5114f85', '1.0.0+21AF26D3----117B344092BD']) {
expect(maker.normalizeWindowsVersion(version)).to.equal('1.0.0.0');
expect(maker.normalizeWindowsVersion(version)).toEqual('1.0.0.0');
}
});
it('does not truncate the version when there is no dash', () => {
expect(maker.normalizeWindowsVersion('2.0.0')).to.equal('2.0.0.0');
expect(maker.normalizeWindowsVersion('2.0.0')).toEqual('2.0.0.0');
});
});
58 changes: 0 additions & 58 deletions packages/maker/base/test/ensure-output_spec.ts

This file was deleted.