Skip to content

Commit

Permalink
Merge pull request #11 from Synthetixio/dev
Browse files Browse the repository at this point in the history
promote dev to master
  • Loading branch information
drptbl authored Dec 3, 2020
2 parents d781973 + 88984a4 commit 4f1222d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
"compilerOptions": {
"allowJs": true,
"baseUrl": "../../node_modules",
"types": ["cypress", "@types/puppeteer-core", "@synthetixio/synpress/support"],
"types": ["cypress", "@types/puppeteer-core", "@synthetixio/synpress/support", "cypress-wait-until", "@testing-library/cypress"],
"outDir": "./output"
},
"include": ["**/*.*"]
Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"node-fetch": "2.6.1",
"prettier": "2.2.1",
"puppeteer-core": "5.5.0",
"puppeteer-recorder": "1.0.7",
"start-server-and-test": "1.11.6",
"unzipper": "0.10.11"
},
Expand Down
25 changes: 6 additions & 19 deletions plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const path = require('path');
const fs = require('fs');
const helpers = require('../helpers');
const puppeteer = require('puppeteer-core');
const { recordPuppeteer } = require('puppeteer-recorder');
const fetch = require('node-fetch');
const { pageElements } = require('../pages/metamask/page');
const {
Expand Down Expand Up @@ -59,6 +58,12 @@ module.exports = (on, config) => {
});

on('task', {
error(message) {
console.error('\u001B[31m', 'ERROR:', message, '\u001B[0m');
},
warn(message) {
console.warn('\u001B[33m', 'WARNING:', message, '\u001B[0m');
},
initPuppeteer: async () => {
const connected = await initPuppeteer();
return connected;
Expand Down Expand Up @@ -110,12 +115,6 @@ module.exports = (on, config) => {

await initPuppeteer();
await assignWindows();
// record puppeteer browser
await record(
puppeteerBrowser,
`${helpers.getSynpressPath()}/puppeteer.webm`,
);
// no suitable element to wait for
await metamaskWindow.waitForTimeout(1000);
if ((await metamaskWindow.$(unlockPageElements.unlockPage)) === null) {
await confirmMetamaskWelcomePage();
Expand Down Expand Up @@ -229,18 +228,6 @@ async function assignWindows() {
return true;
}

async function record(browser, path) {
await recordPuppeteer({
browser: browser,
output: path,
fps: 60,
frames: 60 * 5,
prepare: function () {},
render: function () {},
});
return true;
}

async function switchToCypressWindow() {
await mainWindow.bringToFront();
return true;
Expand Down
7 changes: 0 additions & 7 deletions support/commands.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import '@testing-library/cypress/add-commands';
import 'cypress-wait-until';

Cypress.Commands.add('getId', name => {
if (name.includes('@')) {
return cy.get(`${name}`);
}
return cy.get(`[data-testid="${name}"]`).as(name);
});

Cypress.Commands.add('getDesktopSizes', () => {
return [
[1366, 768],
Expand Down
7 changes: 0 additions & 7 deletions support/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
declare namespace Cypress {
interface Chainable<Subject> {
/**
* Get element using data-testid and sets an alias for it
* @example
* cy.getId('dataTestId')
* cy.getId('alias')
*/
getId(testid: string): Chainable<Subject>;
/**
* Get the most popular desktop resolutions
* @example
Expand Down
12 changes: 12 additions & 0 deletions support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ import { configure } from '@testing-library/cypress';

configure({ testIdAttribute: 'data-testid' });

Cypress.on('window:before:load', win => {
cy.stub(win.console, 'error').callsFake(message => {
cy.now('task', 'error', message);
// fail test on browser console error
// throw new Error(message);
});

cy.stub(win.console, 'warn').callsFake(message => {
cy.now('task', 'warn', message);
});
});

before(() => {
cy.setupMetamask();
});

0 comments on commit 4f1222d

Please sign in to comment.