Skip to content

Commit

Permalink
[smoke] EXPERIMENT: don't go out of the package root.
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitropoulos committed May 17, 2021
1 parent e2e8bf7 commit 9a9b5dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/insomnia-smoke-test/src/modules/application.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Application } from 'spectron';
import path from 'path';
import os from 'os';
// @ts-expect-error -- TSCONVERSION appears to be genuine
import electronPath from '../../../insomnia-app/node_modules/electron';
import mkdirp from 'mkdirp';
import fs from 'fs';
import { Config } from '../entities';

const electronPath = '../../../insomnia-app/node_modules/electron';

const getAppPlatform = () => process.platform;
const isMac = () => getAppPlatform() === 'darwin';
const isLinux = () => getAppPlatform() === 'linux';
Expand Down Expand Up @@ -70,7 +70,9 @@ const launch = async (config?: Config) => {
// Windows spawns two terminal windows when running spectron, and the only workaround
// is to focus the window on start.
// https://github.com/electron-userland/spectron/issues/60
// @ts-expect-error -- TSCONVERSION
await app.browserWindow.focus();
// @ts-expect-error -- TSCONVERSION
await app.browserWindow.setAlwaysOnTop(true);

// Set the implicit wait timeout to 0 (webdriver default)
Expand All @@ -80,6 +82,7 @@ const launch = async (config?: Config) => {
await app.client.setTimeout({ implicit: 0 });

// Set bounds to default size
// @ts-expect-error -- TSCONVERSION
await app.browserWindow.setSize(1280, 700);
});
return app;
Expand All @@ -93,7 +96,6 @@ export const launchApp = async (designerDataPath?: string) => {
export const takeScreenshot = async (app: Application, name: string) => {
mkdirp.sync('screenshots');
const buffer = await app.browserWindow.capturePage();
// @ts-expect-error -- TSCONVERSION appears to be genuine
await fs.promises.writeFile(path.join('screenshots', `${name}.png`), buffer);
};

Expand Down
2 changes: 2 additions & 0 deletions packages/insomnia-smoke-test/src/modules/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export const correctlyLaunched = async (app: Application) => {
// @ts-expect-error -- TSCONVERSION appears to be genuine
await expect(app.browserWindow.isDevToolsOpened()).resolves.toBe(false);
await expect(app.client.getWindowCount()).resolves.toBe(1);
// @ts-expect-error -- TSCONVERSION
await expect(app.browserWindow.isMinimized()).resolves.toBe(false);
// @ts-expect-error -- TSCONVERSION
await expect(app.browserWindow.isFocused()).resolves.toBe(true);
};

Expand Down
6 changes: 3 additions & 3 deletions packages/insomnia-smoke-test/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"rootDir": "src",
"resolveJsonModule": true,
"esModuleInterop": true,
"strict": true
"skipLibCheck": true, // this is required because spectron depends on electron but it is not locatable by typescript for the purpose of types
},
"include": [
"src"
"src",
],
"exclude": [
"src/jest",
"**/*.test.ts"
"**/*.test.ts",
]
}

0 comments on commit 9a9b5dd

Please sign in to comment.