Unverified Commit 8799bd2b authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix chromedriver set-up to test electron separately (#18854)

* Fix chromedriver set-up to test electron separately

* Update workflow

* Update compiled
parent de80b0cc
...@@ -70,6 +70,29 @@ jobs: ...@@ -70,6 +70,29 @@ jobs:
- run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3 - run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3
testElectron:
name: Test Electron
runs-on: ubuntu-latest
needs: build
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
HEADLESS: true
TEST_ELECTRON: 1
steps:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
# TODO: remove after we fix watchpack watching too much
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- run: yarn add -W --dev spectron@7.0.0 electron@5.0.0
- run: xvfb-run node run-tests.js test/integration/with-electron/test/index.test.js
testYarnPnP: testYarnPnP:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
......
...@@ -68,7 +68,6 @@ ...@@ -68,7 +68,6 @@
"coveralls": "3.0.3", "coveralls": "3.0.3",
"cross-env": "6.0.3", "cross-env": "6.0.3",
"cross-spawn": "6.0.5", "cross-spawn": "6.0.5",
"electron": "^5.0.0",
"escape-string-regexp": "2.0.0", "escape-string-regexp": "2.0.0",
"eslint": "6.8.0", "eslint": "6.8.0",
"eslint-plugin-import": "2.20.2", "eslint-plugin-import": "2.20.2",
...@@ -119,7 +118,6 @@ ...@@ -119,7 +118,6 @@
"selenium-standalone": "6.18.0", "selenium-standalone": "6.18.0",
"selenium-webdriver": "4.0.0-alpha.7", "selenium-webdriver": "4.0.0-alpha.7",
"shell-quote": "1.7.2", "shell-quote": "1.7.2",
"spectron": "^7.0.0",
"styled-components": "5.1.0", "styled-components": "5.1.0",
"styled-jsx-plugin-postcss": "3.0.2", "styled-jsx-plugin-postcss": "3.0.2",
"tailwindcss": "1.1.3", "tailwindcss": "1.1.3",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,74 +2,79 @@ ...@@ -2,74 +2,79 @@
import { join } from 'path' import { join } from 'path'
import { nextBuild, nextExport } from 'next-test-utils' import { nextBuild, nextExport } from 'next-test-utils'
import { Application } from 'spectron'
import electron from 'electron'
jest.setTimeout(1000 * 60 * 5) jest.setTimeout(1000 * 60 * 2)
const nextdir = join(__dirname, '../') const nextdir = join(__dirname, '../')
const outdir = join(nextdir, 'out') const outdir = join(nextdir, 'out')
const appdir = join(outdir, 'main.js') const appdir = join(outdir, 'main.js')
let app = null let app = null
describe('Parse Relative Url', () => { if (process.env.TEST_ELECTRON) {
describe('File Protocol via Electron', () => { const electron = require('electron')
beforeAll(async () => { const { Application } = require('spectron')
await nextBuild(nextdir)
await nextExport(nextdir, { outdir })
app = new Application({ describe('Parse Relative Url', () => {
path: electron, describe('File Protocol via Electron', () => {
args: [ beforeAll(async () => {
'--no-sandbox', await nextBuild(nextdir)
'--disable-dev-shm-usage', await nextExport(nextdir, { outdir })
'--disable-gpu',
appdir, app = new Application({
], path: electron,
chromeDriverArgs: [ args: [
'--no-sandbox', '--no-sandbox',
'--disable-dev-shm-usage', '--disable-dev-shm-usage',
'--disable-gpu', '--disable-gpu',
], appdir,
],
chromeDriverArgs: [
'--no-sandbox',
'--disable-dev-shm-usage',
'--disable-gpu',
],
})
await app.start()
}) })
await app.start()
})
afterAll(async () => { afterAll(async () => {
if (app && app.isRunning()) { if (app && app.isRunning()) {
await app.stop() await app.stop()
} }
}) })
it('app init', async () => { it('app init', async () => {
const count = await app.client.getWindowCount() const count = await app.client.getWindowCount()
expect(count).toEqual(1) expect(count).toEqual(1)
}) })
it('should render the home page', async () => { it('should render the home page', async () => {
const text = await app.client.$('#home-page p').getText() const text = await app.client.$('#home-page p').getText()
expect(text).toBe('This is the home page') expect(text).toBe('This is the home page')
}) })
it('should do navigations via Link', async () => { it('should do navigations via Link', async () => {
await app.client.$('#about-via-link').click() await app.client.$('#about-via-link').click()
const text = await app.client.$('#about-page p').getText() const text = await app.client.$('#about-page p').getText()
expect(text).toBe('This is the about page') expect(text).toBe('This is the about page')
}) })
it('should do back to home page via Link', async () => { it('should do back to home page via Link', async () => {
await app.client.$('#about-page a').click() await app.client.$('#about-page a').click()
const text = await app.client.$('#home-page p').getText() const text = await app.client.$('#home-page p').getText()
expect(text).toBe('This is the home page') expect(text).toBe('This is the home page')
}) })
it('should do navigations via Router', async () => { it('should do navigations via Router', async () => {
await app.client.$('#about-via-router').click() await app.client.$('#about-via-router').click()
const text = await app.client.$('#about-page p').getText() const text = await app.client.$('#about-page p').getText()
expect(text).toBe('This is the about page') expect(text).toBe('This is the about page')
})
}) })
}) })
}) } else {
it('Should skip testing electron without process.env.TEST_ELECTRON set', () => {})
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment