Skip to content
Permalink
Browse files

Test fixes

  • Loading branch information...
bluepnume committed Nov 27, 2018
1 parent 673819b commit 69f56638d1a22bcd62f0db6435d6055dc8645142
@@ -1,23 +1,13 @@
language: node_js
node_js:
- "8"
- "10"
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sudo sh -c "echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections"
- sudo aptitude -y install ttf-mscorefonts-installer > /dev/null
- sudo fc-cache
- sudo apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
before_script:
- npm run flow-typed
script:
- npm run test
- npm run build
sudo: required
dist: trusty
dist: xenial
addons:
firefox: "52.0"
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
chrome: stable
@@ -65,6 +65,10 @@ export function containerTemplate({ id, props, CLASS, on, container, tag, contex

const size = BUTTON_SIZE.RESPONSIVE;

if (!container) {
throw new Error(`Expected container`);
}

const getContainerDimensions = () => {
let cont = container;

@@ -4,8 +4,7 @@ import './tests';

window.mockDomain = 'mock://www.merchant-site.com';

const MAX_OVERALL_MEMORY = 800;
const MAX_TEST_MEMORY = 80;
const MEM_PER_TEST = 2;

const memoryReported = (window.performance && window.performance.memory &&
window.performance.memory.usedJSHeapSize);
@@ -14,12 +13,12 @@ function getMemory() : number {
return window.performance.memory.usedJSHeapSize / Math.pow(2, 20);
}

let startMem;
let maxMem = getMemory();
let originalUserAgent;

beforeEach(() => {
if (memoryReported) {
startMem = getMemory();
maxMem += MEM_PER_TEST;
}

// eslint-disable-next-line unicorn/prefer-add-event-listener
@@ -35,7 +34,6 @@ beforeEach(() => {
});

afterEach(() => {

window.localStorage.clear();
delete window.__paypal_storage__;
delete window.__paypal_global__;
@@ -47,22 +45,19 @@ afterEach(() => {

delete window.document.documentMode;

if (window.gc) {
window.gc();
}
return window.paypal.destroyAll();
});

after(() => {
if (memoryReported) {
const mem = getMemory();
const diff = mem - startMem;

if (mem > MAX_OVERALL_MEMORY) {
throw new Error(`Overall memory exceeded ${ MAX_OVERALL_MEMORY }mb - ${ mem.toFixed(2) }`);
if (window.gc) {
window.gc();
}

if (diff > MAX_TEST_MEMORY) {
throw new Error(`Test memory exceeded ${ MAX_TEST_MEMORY }mb - ${ diff.toFixed(2) }`);
const mem = getMemory();

if (mem > maxMem) {
throw new Error(`Overall memory exceeded ${ parseInt(maxMem, 10) }mb - ${ mem.toFixed(2) }mb used`);
}
}

return window.paypal.destroyAll();
});
@@ -14,7 +14,7 @@ import { readPNG, type PngType } from './image';

export async function openPage(scriptURL : string, { headless = true } : { headless : boolean }) : Promise<Object> {

const browser = await puppeteer.launch({ headless });
const browser = await puppeteer.launch({ headless, args: [ '--no-sandbox' ] });
const page = await browser.newPage();

page.emulate({
@@ -30,7 +30,7 @@ if (bridge) {
function renderCheckout(props = {}) {


window.paypal.Checkout.renderTo(window.xchild.getParentRenderWindow(), {
window.paypal.Checkout.renderTo(window.parent, {

payment: window.xprops.createOrder,
onAuthorize(data, actions) : void | ZalgoPromise<void> {
@@ -65,7 +65,7 @@ if (action === 'checkout') {
testButton.addEventListener('click', () => {
window.xchild.hide();

window.paypal.Checkout.renderPopupTo(window.xchild.getParentRenderWindow(), {
window.paypal.Checkout.renderPopupTo(window.opener ? window.opener.parent : window.parent, {
payment: window.xprops.payment,
onAuthorize: window.xprops.onAuthorize,
onCancel: window.xprops.onCancel,

0 comments on commit 69f5663

Please sign in to comment.
You can’t perform that action at this time.