Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
> **Warning**
>
> This repo is being archived as I no longer have time to keep up with new features and support requests.
> If you're interested in taking it over, please email or [DM me](https://twitter.com/Dierkens03)

---

<h1 align="center">
<img width="400" alt="proof" src="./packages/docs/src/media/proof.color.text.svg"/>
</h1>
Expand All @@ -19,9 +12,6 @@
<a href="#"><img alt="Forks" src="https://img.shields.io/github/forks/intuit/proof?style=social"></a>
</p>




Storybook is a great tool for developing components -- and while simulated and snapshot based testing can get you _pretty_ far, there's no substitution for the real thing. `proof` is a tapable integration testing library for your stories.

## Usage
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@
}
},
"devDependencies": {
"@design-systems/eslint-config": "1.4.8",
"@types/jest": "25.1.4",
"@typescript-eslint/parser": "2.25.0",
"@design-systems/eslint-config": "4.15.1",
"@types/jest": "28.1.3",
"@typescript-eslint/parser": "5.31.0",
"auto": "10.27.1",
"eslint-plugin-no-explicit-type-exports": "0.10.11",
"eslint-plugin-no-explicit-type-exports": "0.12.1",
"husky": "4.2.3",
"jest": "25.2.3",
"jest-junit": "10.0.0",
"jest": "28.1.3",
"jest-junit": "14.0.0",
"lerna": "^3.20.2",
"lint-staged": "10.0.9",
"lint-staged": "13.0.3",
"prettier": "2.0.2",
"ts-jest": "25.2.1",
"typescript": "3.8.3"
"ts-jest": "28.0.7",
"typescript": "4.7.4"
},
"prettier": {
"singleQuote": true
Expand Down
5 changes: 2 additions & 3 deletions packages/browser/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const base = require('../../jest.config.base');
const {name} = require('./package.json');
const { name } = require('./package.json');

module.exports = {
...base,
name,
displayName: name
displayName: name,
};
4 changes: 2 additions & 2 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"@types/url-parse": "1.4.3",
"chalk": "^3.0.0",
"progress": "^2.0.3",
"selenium-standalone": "^6.17.0",
"selenium-standalone": "8.2.0",
"tapable": "^1.1.3",
"url-join": "4.0.1",
"url-parse": "1.4.7",
"webdriverio": "6.1.22"
"webdriverio": "7.20.7"
}
}
6 changes: 2 additions & 4 deletions packages/browser/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as webdriver from 'webdriverio';

const grids = ['local', 'remote'] as const;
export type Grid = typeof grids[number];

export type Browser = webdriver.BrowserObject;
export type Browser = WebdriverIO.Browser;

const browserNames = [
'chrome',
Expand All @@ -14,7 +12,7 @@ const browserNames = [
] as const;

export type BrowserName = typeof browserNames[number];
export type GridOptions = Record<Grid, object>;
export type GridOptions = Record<Grid, any>;
export interface BrowserConfig {
name: BrowserName;
platform?: string;
Expand Down
64 changes: 19 additions & 45 deletions packages/browser/src/local-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,78 +6,52 @@ import Progress from 'progress';
export class LocalGrid {
install: Promise<void>;

process?: Promise<ChildProcess>;
process?: ChildProcess;

constructor(options?: { install?: boolean }) {
let progress: Progress;

if (options?.install) {
this.install = new Promise((resolve, reject) => {
selenium.install(
{
progressCb(total: number, progressLength: number, chunk: number) {
progress =
progress ||
new Progress('Selenium installation [:bar] :percent :etas', {
total,
complete: '=',
incomplete: ' ',
width: 20,
});

progress.tick(chunk);
},
},
(err: any, paths: any) => {
if (err) {
return reject(err);
}

resolve(paths);
}
);
this.install = selenium.install({
progressCb(total: number, progressLength: number, chunk: number) {
progress =
progress ||
new Progress('Selenium installation [:bar] :percent :etas', {
total,
complete: '=',
incomplete: ' ',
width: 20,
});

progress.tick(chunk);
},
});
} else {
this.install = Promise.resolve();
}
}

start(port = 4444): Promise<ChildProcess> {
async start(port = 4444): Promise<ChildProcess> {
if (this.process) {
return this.process;
}

this.process = this.install.then(() => {
return new Promise((resolve, reject) => {
selenium.start(
{ seleniumArgs: ['-port', `${port}`] },
(err: any, child: ChildProcess) => {
if (err) {
// return reject(err);
}
await this.install;

return resolve(child);
}
);
});
this.process = await selenium.start({
seleniumArgs: ['--port', `${port}`],
});

return this.process;
}

end() {
if (this.process) {
const end = this.process.then((child) => {
if (child) {
child.kill();
}
});
const end = this.process.kill();

this.process = undefined;
return end;
}

return Promise.resolve();
}
}

Expand Down
9 changes: 5 additions & 4 deletions packages/browser/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import chalk from 'chalk';
import { remote, BrowserObject } from 'webdriverio';
import { remote } from 'webdriverio';
import { AsyncSeriesHook, SyncWaterfallHook, SyncHook } from 'tapable';
import { createLogger } from '@proof-ui/logger';
import urlJoin from 'url-join';
import { normalizeBaseURL, getStoryURL } from './url';
import { BrowserConfig, Grid } from './common';
import localGrid from './local-grid';
import getWDLogger from '@wdio/logger';
import { WebDriverLogTypes } from '@wdio/types/build/Options';

const loggers = ['webdriver', 'webdriverio', 'devtools'];
loggers.forEach((name) => {
Expand All @@ -28,7 +29,7 @@ loggers.forEach((name) => {
export * from './common';

export interface BrowserSession extends BrowserSessionOptions {
browser: BrowserObject;
browser: WebdriverIO.Browser;
config: BrowserConfig;
url: string;
}
Expand All @@ -53,7 +54,7 @@ const DefaultGridOptions: Record<Grid, any> = {
},
};

function convertToBrowserLevel(logLevel: WebDriver.WebDriverLogTypes): string {
function convertToBrowserLevel(logLevel: WebDriverLogTypes): string {
switch (logLevel) {
case 'warn':
case 'error':
Expand Down Expand Up @@ -92,7 +93,7 @@ export default class BrowserFactory {
constructor(options: {
config: BrowserConfig;
storybookBaseURL: string;
logLevel: WebDriver.WebDriverLogTypes;
logLevel: WebDriverLogTypes;
waitForRoot?: number;
}) {
this.config = options.config;
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const cmd: Command = {
footer: [
{
header: 'Version',
// eslint-disable-next-line @typescript-eslint/no-var-requires
content: require('../package.json').version,
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class Proof {
}
);
} catch (error) {
testResult.error = error;
testResult.error = error as Error;
}

const endTime = Date.now();
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/storybook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function getStories(
const getStoriesFromBrowser = async () => {
await browser.switchToFrame(await browser.$('#storybook-preview-iframe'));

return browser.execute<StoryboookAPI>(
return browser.execute<StoryboookAPI, []>(
'return __STORYBOOK_CLIENT_API__.getStorybook()'
);
};
Expand All @@ -49,7 +49,10 @@ export async function getStories(
stories = await promiseRetry(
getStoriesFromBrowser,
3,
() => new Promise((r) => setTimeout(() => r, 1000))
() =>
new Promise<void>((r) => {
setTimeout(() => r, 1000);
})
);
} catch (error) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function promiseRetry<T>(
return await promiseGenerator();
} catch (error) {
if (onFail) {
await onFail(error, retryCount);
await onFail(error as Error, retryCount);
}

return promiseRetry(promiseGenerator, retryCount - 1, onFail);
Expand Down
2 changes: 1 addition & 1 deletion packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@proof-ui/browser": "link:../browser",
"webdriverio": "6.1.22"
"webdriverio": "7.20.7"
},
"publishConfig": {
"access": "public",
Expand Down
4 changes: 1 addition & 3 deletions packages/test/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Browser } from 'webdriverio';

export type TestService = (
config: TestConfig,
callback: TestCallback,
file: string
) => void;

export interface TestArgs {
browser: Browser;
browser: WebdriverIO.Browser;
story: string;
kind: string;
}
Expand Down
4 changes: 1 addition & 3 deletions plugins/applitools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"build:watch": "npm run build -- -w"
},
"dependencies": {
"@applitools/eyes-selenium": "4.44.0",
"@applitools/eyes-webdriverio": "5.21.0",
"selenium-webdriver": "4.0.0-alpha.7"
"@applitools/eyes-webdriverio": "5.35.7"
},
"peerDependencies": {
"@proof-ui/cli-plugin": "*",
Expand Down
14 changes: 14 additions & 0 deletions plugins/applitools/src/createApplitoolsLogHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Logger as ApplitoolsLogger } from '@applitools/eyes-webdriverio';
import { Logger } from '@proof-ui/logger';

export default (proofLogger: Logger) => {
return new ApplitoolsLogger({
show: true,
handler: {
log: (message: string) => proofLogger.trace(message),
warn: (message: string) => proofLogger.warn(message),
error: (message: string) => proofLogger.error(message),
fatal: (message: string) => proofLogger.fatal(message),
},
}).getLogHandler();
};
Loading