mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
8585eea9e6
* now with 100% fat free cancellation Co-authored-by: James Gatz <jamesgatzos@gmail.com> * unblock electron 15 * fix cookielist and temp fix curl types * fix types * fix inso * default to verbose inso test * implement readdata function * fix test * revert test changes * isomorphic cancel * reduce typing issues * curl types * turns out the tests were wrong * handle errors * remove unused inso mock * remove request delay * fix lint and add logs * Revert "remove request delay" This reverts commit f07d8c90a7a7279ca10f8a8de1ea0c82caa06390. * simplify and add cancel fallback * skip cancel test * playwright is fast and insomnia is slow * trailing spaces are serious yo * cancel is flake town * hmm * unblock nunjucks and storeTimeline * fix nunjucks tests * preload writeFile * oops forgot to remove the reload * debugging CI takes all day, log stuff and pray * also warn if nunjucks is being lame * Stop using environment variables * revert debugging logs Co-authored-by: James Gatz <jamesgatzos@gmail.com> Co-authored-by: David Marby <david@dmarby.se>
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
// Read more about creating fixtures https://playwright.dev/docs/test-fixtures
|
|
import { ElectronApplication, test as baseTest, TraceMode } from '@playwright/test';
|
|
import path from 'path';
|
|
|
|
import {
|
|
bundleType,
|
|
cwd,
|
|
executablePath,
|
|
mainPath,
|
|
randomDataPath,
|
|
} from './paths';
|
|
|
|
interface EnvOptions {
|
|
INSOMNIA_DATA_PATH: string;
|
|
}
|
|
|
|
export const test = baseTest.extend<{
|
|
app: ElectronApplication;
|
|
}>({
|
|
app: async ({ playwright, trace }, use, testInfo) => {
|
|
const options: EnvOptions = {
|
|
INSOMNIA_DATA_PATH: randomDataPath(),
|
|
};
|
|
|
|
const electronApp = await playwright._electron.launch({
|
|
cwd,
|
|
executablePath,
|
|
args: bundleType() === 'package' ? [] : [mainPath],
|
|
env: {
|
|
...process.env,
|
|
...options,
|
|
PLAYWRIGHT: 'true',
|
|
},
|
|
});
|
|
|
|
const appContext = electronApp.context();
|
|
const traceMode: TraceMode = typeof trace === 'string' ? trace as TraceMode : trace.mode;
|
|
|
|
const defaultTraceOptions = { screenshots: true, snapshots: true, sources: true };
|
|
const traceOptions = typeof trace === 'string' ? defaultTraceOptions : { ...defaultTraceOptions, ...trace, mode: undefined };
|
|
const captureTrace = (traceMode === 'on' || traceMode === 'retain-on-failure' || (traceMode === 'on-first-retry' && testInfo.retry === 1));
|
|
|
|
if (captureTrace) {
|
|
await appContext.tracing.start(traceOptions);
|
|
}
|
|
|
|
await use(electronApp);
|
|
|
|
if (captureTrace) {
|
|
await appContext.tracing.stop({
|
|
path: path.join(testInfo.outputDir, 'trace.zip'),
|
|
});
|
|
}
|
|
|
|
await electronApp.close();
|
|
},
|
|
page: async ({ app }, use) => {
|
|
const page = await app.firstWindow();
|
|
|
|
await page.waitForLoadState();
|
|
|
|
await page.click("text=Don't share usage analytics");
|
|
|
|
await use(page);
|
|
},
|
|
});
|