-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor fast suite to use vitest (#3797)
* i guess this works * remove resolution * checkpoint * clean up :) * forgot to push up lockfile * resolveDir spec * upgrade-forge-config tests * convert start tests + cleanup * install-dependencies * delete superseded tests * appx tests * makerbase tests * makerdeb test * makerdmg tests * flatpak and pkg * rpm tests * maker snap * wix * maker-zip tests * local electron plugin * webpack plugin tests * vite tests * MSW a few publishers * publisher github * finish up tests * remove packages * generalize assertion for publish test * increase test timeout * use junit reporter in CI * turn down parallelism? * fixes :) * add xvfb-maybe * increase timeout again on npm install in asset relocator patch test * debug statement * does this fix it? * fully migrate to jest-like matchers * make timeout longer * increase test timeout again
- Loading branch information
Showing
123 changed files
with
4,742 additions
and
3,766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/api/cli/test/check-system_spec.ts → packages/api/cli/spec/check-system.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { expect } from 'chai'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { checkValidPackageManagerVersion } from '../src/util/check-system'; | ||
|
||
describe('check-system', () => { | ||
describe('validPackageManagerVersion', () => { | ||
it('should consider whitelisted versions to be valid', () => { | ||
expect(() => checkValidPackageManagerVersion('NPM', '3.10.1', '^3.0.0')).to.not.throw(); | ||
expect(() => checkValidPackageManagerVersion('NPM', '3.10.1', '^3.0.0')).not.toThrow(); | ||
}); | ||
|
||
it('should consider Yarn nightly versions to be invalid', () => { | ||
expect(() => checkValidPackageManagerVersion('Yarn', '0.23.0-20170311.0515', '0.23.0')).to.throw(); | ||
expect(() => checkValidPackageManagerVersion('Yarn', '0.23.0-20170311.0515', '0.23.0')).toThrow(); | ||
}); | ||
|
||
it('should consider invalid semver versions to be invalid', () => { | ||
expect(() => checkValidPackageManagerVersion('Yarn', '0.22', '0.22.0')).to.throw(); | ||
expect(() => checkValidPackageManagerVersion('Yarn', '0.22', '0.22.0')).toThrow(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import path from 'node:path'; | ||
|
||
import { spawn } from '@malept/cross-spawn-promise'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
function runForgeCLI(...extraArgs: string[]): Promise<string> { | ||
const args = ['ts-node', path.resolve(__dirname, '../src/electron-forge.ts'), ...extraArgs]; | ||
return spawn('npx', args); | ||
} | ||
|
||
describe('cli', { timeout: 30_000 }, () => { | ||
it('should not fail on known subcommands', async () => { | ||
await expect(runForgeCLI('help')).resolves.toMatch(/Usage:/); | ||
}); | ||
|
||
it('should fail on unknown subcommands', async () => { | ||
await expect(runForgeCLI('nonexistent')).rejects.toThrow(Error); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* eslint-disable node/no-unsupported-features/es-syntax */ | ||
import * as path from 'node:path'; | ||
|
||
import { describe, expect, it, vi } from 'vitest'; | ||
|
||
import make from '../../src/api/make'; | ||
|
||
vi.mock(import('@electron-forge/core-utils'), async (importOriginal) => { | ||
const mod = await importOriginal(); | ||
return { | ||
...mod, | ||
getElectronVersion: vi.fn().mockResolvedValue('1.0.0'), | ||
}; | ||
}); | ||
|
||
describe('make', () => { | ||
const fixtureDir = path.resolve(__dirname, '../../test/fixture'); | ||
|
||
it.todo('should call "package"'); | ||
|
||
it('works with @scoped package names', { timeout: 10_000 }, async () => { | ||
const result = await make({ | ||
arch: 'x64', | ||
dir: path.join(fixtureDir, 'app-with-scoped-name'), | ||
platform: 'linux', | ||
skipPackage: true, | ||
}); | ||
expect(result).toHaveLength(1); | ||
expect(result[0].artifacts).toEqual([expect.stringContaining('@scope-package-linux-x64-1.0.0.zip')]); | ||
}); | ||
|
||
it('can override targets', async () => { | ||
const results = await make({ | ||
arch: 'x64', | ||
dir: path.join(fixtureDir, 'app-with-custom-maker-config'), | ||
overrideTargets: ['../custom-maker'], | ||
platform: 'linux', | ||
skipPackage: true, | ||
}); | ||
|
||
expect(results[0].artifacts).toEqual(['from config']); | ||
}); | ||
|
||
it('throws an error if the name is not a string', async () => { | ||
await expect( | ||
make({ | ||
arch: 'x64', | ||
dir: path.join(fixtureDir, 'maker-name-wrong-type'), | ||
platform: 'linux', | ||
skipPackage: true, | ||
}) | ||
).rejects.toThrowError(/^The following maker config has a maker name that is not a string:/); | ||
}); | ||
|
||
it('throws an error if the name is missing', async () => { | ||
await expect( | ||
make({ | ||
arch: 'x64', | ||
dir: path.join(fixtureDir, 'maker-sans-name'), | ||
platform: 'linux', | ||
skipPackage: true, | ||
}) | ||
).rejects.toThrowError(/^The following maker config is missing a maker name:/); | ||
}); | ||
|
||
it('can skip makers via config', async () => { | ||
await expect( | ||
make({ | ||
arch: 'x64', | ||
dir: path.join(fixtureDir, 'app-with-maker-disable'), | ||
platform: 'linux', | ||
skipPackage: true, | ||
}) | ||
).rejects.toThrowError(/Could not find any make targets configured for the "linux" platform./); | ||
}); | ||
|
||
it('throws if maker cannot be resolved', async () => { | ||
const opts = { | ||
arch: 'x64', | ||
dir: path.join(fixtureDir, 'app-with-custom-maker-config'), | ||
platform: 'linux', | ||
skipPackage: true, | ||
}; | ||
|
||
await expect(make(opts)).rejects.toThrowError("Could not find module with name '@electron-forge/non-existent-forge-maker'"); | ||
}); | ||
}); |
Oops, something went wrong.