Skip to content

Commit

Permalink
move nearest package tests to units
Browse files Browse the repository at this point in the history
  • Loading branch information
goosewobbler committed Oct 9, 2023
1 parent 167c3f8 commit 3b70e31
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 9 deletions.
8 changes: 0 additions & 8 deletions example/e2e/config/wdio.conf.ts

This file was deleted.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"ci": "pnpm i && pnpm build && pnpm test",
"clean": "pnpm clean:dist && rm -rf ./node_modules pnpm-lock.yaml ./all-logs",
"clean:dist": "pnpx rimraf ./dist && mkdir -p ./dist",
"test": "wdio run ./wdio.conf.ts && wdio run ./e2e/config/wdio.conf.ts"
"test": "wdio run ./wdio.conf.ts"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.4",
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/electron-in-dependencies/subpackage/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "fixture-electron-in-dependencies-subpackage",
"version": "1.0.0",
"description": "Electron found in dependencies",
"scripts": {},
"dependencies": {
"electron": "^26.0.0"
},
"devDependencies": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This empty dir is required for testing reading the nearest package.json
# Ignore everything
*
# Except this file
!.gitignore
10 changes: 10 additions & 0 deletions test/fixtures/electron-in-dev-dependencies/subpackage/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "fixture-electron-in-dev-dependencies-subpackage",
"version": "1.0.0",
"description": "Electron found in devDependencies",
"scripts": {},
"dependencies": {},
"devDependencies": {
"electron": "^26.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This empty dir is required for testing reading the nearest package.json
# Ignore everything
*
# Except this file
!.gitignore
52 changes: 52 additions & 0 deletions test/launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,32 @@ describe('onPrepare', () => {
});
});

it('should use the Electron version from the nearest package dependencies when browserVersion is not provided', async () => {
instance = new LaunchService(
options,
[] as never,
{
services: [['electron', options]],
rootDir: path.join(process.cwd(), 'test', 'fixtures', 'electron-in-dependencies', 'subpackage', 'subdir'),
} as Options.Testrunner,
);
const capabilities: Capabilities.Capabilities[] = [
{
browserName: 'electron',
},
];
await instance?.onPrepare({} as never, capabilities);
expect(capabilities[0]).toEqual({
'browserName': 'chrome',
'browserVersion': '116.0.5845.82',
'goog:chromeOptions': {
args: [],
binary: 'workspace/my-test-app/dist/my-test-app',
windowTypes: ['app', 'webview'],
},
});
});

it('should use the Electron version from the local package devDependencies when browserVersion is not provided', async () => {
instance = new LaunchService(
options,
Expand All @@ -165,6 +191,32 @@ describe('onPrepare', () => {
});
});

it('should use the Electron version from the nearest package devDependencies when browserVersion is not provided', async () => {
instance = new LaunchService(
options,
[] as never,
{
services: [['electron', options]],
rootDir: path.join(process.cwd(), 'test', 'fixtures', 'electron-in-dev-dependencies', 'subpackage', 'subdir'),
} as Options.Testrunner,
);
const capabilities: Capabilities.Capabilities[] = [
{
browserName: 'electron',
},
];
await instance?.onPrepare({} as never, capabilities);
expect(capabilities[0]).toEqual({
'browserName': 'chrome',
'browserVersion': '116.0.5845.82',
'goog:chromeOptions': {
args: [],
binary: 'workspace/my-test-app/dist/my-test-app',
windowTypes: ['app', 'webview'],
},
});
});

it('should throw an error when browserVersion is not provided and there is no local Electron version', async () => {
instance = new LaunchService(
options,
Expand Down

0 comments on commit 3b70e31

Please sign in to comment.