diff --git a/.circleci/config.yml b/.circleci/config.yml index 5fc02f623e5..fb826c7d97a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,14 +51,14 @@ jobs: steps: - attach_workspace: at: ~/stencil - - run: npm run test.end-to-end -- --ci --debug --max-workers=4 + - run: npm run test.end-to-end -- --ci test_jest: <<: *defaults steps: - attach_workspace: at: ~/stencil - - run: npm run test.jest -- --max-workers=4 + - run: npm run test.jest -- --maxWorkers=1 test_sys_node: <<: *defaults diff --git a/src/runtime/test/globals.spec.tsx b/src/runtime/test/globals.spec.tsx index 55c50ff5a5c..99594f51d76 100644 --- a/src/runtime/test/globals.spec.tsx +++ b/src/runtime/test/globals.spec.tsx @@ -49,10 +49,10 @@ describe('globals', () => { html: `` }); - expect(page.rootInstance.proto).toBe(Element.prototype); - expect(page.rootInstance.proto).toBe((page.win as any).Element.prototype); - expect(page.rootInstance.proto).toBe((window as any).Element.prototype); - expect(page.rootInstance.proto).toBe((global as any).Element.prototype); + expect(page.rootInstance.proto).toEqual(Element.prototype); + expect(page.rootInstance.proto).toEqual((page.win as any).Element.prototype); + expect(page.rootInstance.proto).toEqual((window as any).Element.prototype); + expect(page.rootInstance.proto).toEqual((global as any).Element.prototype); expect(page.rootInstance.proto).toBeTruthy(); }); }); diff --git a/src/screenshot/connector-base.ts b/src/screenshot/connector-base.ts index 525e3eaf959..b07aa41a48c 100644 --- a/src/screenshot/connector-base.ts +++ b/src/screenshot/connector-base.ts @@ -47,7 +47,7 @@ export class ScreenshotConnector implements d.ScreenshotConnector { this.packageDir = opts.packageDir; this.rootDir = opts.rootDir; this.appNamespace = opts.appNamespace; - this.timeoutBeforeScreenshot = typeof opts.timeoutBeforeScreenshot === 'number' ? opts.timeoutBeforeScreenshot : 4; + this.timeoutBeforeScreenshot = typeof opts.timeoutBeforeScreenshot === 'number' ? opts.timeoutBeforeScreenshot : 0; this.pixelmatchModulePath = opts.pixelmatchModulePath; if (!opts.logger) { diff --git a/src/testing/jest/jest-config.ts b/src/testing/jest/jest-config.ts index 79ec8d4c710..8a706673397 100644 --- a/src/testing/jest/jest-config.ts +++ b/src/testing/jest/jest-config.ts @@ -9,11 +9,10 @@ export function buildJestArgv(config: d.Config) { ...config.flags.knownArgs.slice() ]; - if (config.flags.e2e && config.flags.ci && !args.some(a => a.startsWith('--max-workers') || a.startsWith('--maxWorkers'))) { - args.push('--maxWorkers=4'); - } - if (config.flags.devtools) { - args.push('--maxWorkers=1'); + if (config.flags.e2e && (config.flags.ci || config.flags.devtools)) { + if (!args.some(a => a.startsWith('--max-workers') || a.startsWith('--maxWorkers'))) { + args.push('--max-workers=1'); + } args.push('--runInBand'); } @@ -21,7 +20,6 @@ export function buildJestArgv(config: d.Config) { const { options } = require('jest-cli/build/cli/args'); const jestArgv = yargs(args).options(options).argv as d.JestArgv; - jestArgv.config = buildJestConfig(config); return jestArgv; diff --git a/src/testing/jest/jest-screenshot.ts b/src/testing/jest/jest-screenshot.ts index 1464f24046e..dab9d29aa92 100644 --- a/src/testing/jest/jest-screenshot.ts +++ b/src/testing/jest/jest-screenshot.ts @@ -9,8 +9,7 @@ export async function runJestScreenshot(config: d.Config, env: d.E2EProcessEnv) const connector: d.ScreenshotConnector = new ScreenshotConnector(); // for CI, let's wait a little longer than locally before taking the screenshot - const timeoutBeforeScreenshot = config.flags.ci ? 30 : 10; - + const timeoutBeforeScreenshot = 0; const pixelmatchModulePath = config.sys.path.join(config.sys.compiler.packageDir, 'screenshot', 'pixel-match.js'); config.logger.debug(`pixelmatch module: ${pixelmatchModulePath}`); diff --git a/src/testing/jest/test/jest-config.spec.ts b/src/testing/jest/test/jest-config.spec.ts index 65c953070cb..93a9f33c197 100644 --- a/src/testing/jest/test/jest-config.spec.ts +++ b/src/testing/jest/test/jest-config.spec.ts @@ -25,13 +25,13 @@ describe('jest-config', () => { it('pass --maxWorkers=2 arg when e2e test and --ci', () => { const process: any = { - argv: ['node', 'stencil', 'test', '--ci', '--e2e', '--maxWorkers=2'] + argv: ['node', 'stencil', 'test', '--ci', '--e2e', '--max-workers=2'] }; const config = mockConfig(); config.flags = parseFlags(process); config.testing = {}; - expect(config.flags.args).toEqual(['--ci', '--e2e', '--maxWorkers=2']); + expect(config.flags.args).toEqual(['--ci', '--e2e', '--max-workers=2']); expect(config.flags.unknownArgs).toEqual([]); const jestArgv = buildJestArgv(config); @@ -52,7 +52,7 @@ describe('jest-config', () => { const jestArgv = buildJestArgv(config); expect(jestArgv.ci).toBe(true); - expect(jestArgv.maxWorkers).toBe(4); + expect(jestArgv.maxWorkers).toBe(1); }); it('pass --maxWorkers=2 arg to jest', () => { diff --git a/src/testing/puppeteer/puppeteer-screenshot.ts b/src/testing/puppeteer/puppeteer-screenshot.ts index aef5da6d6fb..28f15388492 100644 --- a/src/testing/puppeteer/puppeteer-screenshot.ts +++ b/src/testing/puppeteer/puppeteer-screenshot.ts @@ -84,24 +84,20 @@ export async function pageCompareScreenshot(page: pd.E2EPageInternal, env: d.E2E const emulateConfig = JSON.parse(env.__STENCIL_EMULATE__) as d.EmulateConfig; const screenshotBuildData = JSON.parse(env.__STENCIL_SCREENSHOT_BUILD__) as d.ScreenshotBuildData; - await (page as any).waitForNavigation({ - timeout: screenshotBuildData.timeoutBeforeScreenshot, - waitUntil: 'networkidle0' - }); - + await wait(screenshotBuildData.timeoutBeforeScreenshot); await page.evaluate(() => { return new Promise(resolve => { - window.requestAnimationFrame(() => { - resolve(); - }); + (window as any).requestIdleCallback(() => { + window.requestAnimationFrame(() => { + resolve(); + }); + }, { timeout: 100 }); }); }); const screenshotOpts = createPuppeteerScreenshopOptions(opts); const screenshotBuf = await page.screenshot(screenshotOpts); - const pixelmatchThreshold = (typeof opts.pixelmatchThreshold === 'number' ? opts.pixelmatchThreshold : screenshotBuildData.pixelmatchThreshold); - const results = await compareScreenshot(emulateConfig, screenshotBuildData, screenshotBuf, desc, testPath, pixelmatchThreshold); return results; @@ -127,3 +123,7 @@ function createPuppeteerScreenshopOptions(opts: d.ScreenshotOptions) { return puppeteerOpts; } + +function wait(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); +} diff --git a/test/karma/karma.config.js b/test/karma/karma.config.js index 21f060896e4..35d58ea9dda 100644 --- a/test/karma/karma.config.js +++ b/test/karma/karma.config.js @@ -30,7 +30,7 @@ var browserStackLaunchers = { base: 'BrowserStack', browser: 'safari', os: 'OS X', - os_version: 'High Sierra' + os_version: 'Mojave' } }; diff --git a/test/karma/test-app/attribute-complex/index.html b/test/karma/test-app/attribute-complex/index.html index 953eeb60f37..f5e8ac4866f 100644 --- a/test/karma/test-app/attribute-complex/index.html +++ b/test/karma/test-app/attribute-complex/index.html @@ -6,8 +6,10 @@ \ No newline at end of file diff --git a/test/karma/test-app/esm-import/karma.spec.ts b/test/karma/test-app/esm-import/karma.spec.ts index c1c6fc78b55..8d4e7c53d41 100644 --- a/test/karma/test-app/esm-import/karma.spec.ts +++ b/test/karma/test-app/esm-import/karma.spec.ts @@ -65,7 +65,7 @@ if (typeof (window as any).CustomEvent !== 'function') { } function buttonClick(button: HTMLButtonElement) { - // const event = new (window as any).CustomEvent('click', { 'bubbles': true, composed: true } as any); - // button.dispatchEvent(event); - button.click(); + const event = new (window as any).CustomEvent('click', { 'bubbles': true, composed: true } as any); + button.dispatchEvent(event); + // button.click(); }