-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
565 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Contribution guide | ||
|
||
> This document is currently a work in progress and is not yet comprehensive. | ||
> Additional info will be added over time. | ||
### Running e2e tests | ||
|
||
End-to-end testing of html-reporter consists of two stages: generating fixture reports using different tools and tests, | ||
then running hermione tests on these reports. | ||
|
||
In order to make e2e/screenshot tests stable and reproducible across different environments, | ||
you need to launch browsers inside a Docker container. | ||
|
||
1. Make sure you have Docker installed. | ||
<details><summary>How to?</summary> | ||
1. If you want to make a personal open-source contribution, you may use Docker free of charge and follow the [official guide](https://docs.docker.com/get-docker/). | ||
2. If you are acting on behalf of a company, you may not have access to Docker Desktop. In this case: | ||
- On Linux, you may follow the official installation guide. | ||
- On Mac, you may use [colima](https://github.com/abiosoft/colima) as a replacement for Docker Desktop. | ||
- On Windows, you may use Windows Subsystem for Linux to run the Docker CLI without the Desktop application. | ||
</details> | ||
2. Run e2e tests: | ||
```bash | ||
npm run e2e | ||
``` | ||
|
||
If you want a finer-grained control over the process, the following commands are available: | ||
- `npm run e2e:build-browsers` — build Docker image with browsers | ||
- `npm run e2e:launch-browsers` — launch selenium standalone server inside Docker | ||
- `npm run e2e:generate-fixture-report` — generate fixture report to run tests on | ||
- `npm run e2e:test` — run e2e tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM cimg/node:16.20-browsers | ||
|
||
ENV CHROME_VERSION=116 | ||
|
||
USER circleci | ||
|
||
COPY --chown=circleci browser-utils browser-utils | ||
WORKDIR browser-utils | ||
|
||
RUN npm ci && \ | ||
# The download script outputs progress messages, but we need only final path, hence we filter output here | ||
CHROME_PATH=$(node ./download-chromium.js |& grep '^/home') && \ | ||
CHROME_PATH=$(dirname $CHROME_PATH) && \ | ||
mkdir ~/browsers && \ | ||
mv $CHROME_PATH ~/browsers/chrome-linux | ||
|
||
RUN npm install [email protected] -g && \ | ||
selenium-standalone install --drivers.chrome.version=$CHROME_VERSION | ||
|
||
ENTRYPOINT selenium-standalone start --drivers.chrome.version=$CHROME_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const os = require('os'); | ||
const path = require('path'); | ||
const downloadChromium = require('hermione-headless-chrome/lib/download-chromium-by-version'); | ||
|
||
downloadChromium(process.env.CHROME_VERSION, path.join(os.homedir(), 'chrome-cache'), 10) | ||
.then(chromePath => console.log(chromePath)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "browser-utils", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": {}, | ||
"dependencies": { | ||
"hermione-headless-chrome": "1.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs/promises'); | ||
const path = require('path'); | ||
const util = require('util'); | ||
const _ = require('lodash'); | ||
const inquirer = require('inquirer'); | ||
const program = require('@gemini-testing/commander'); | ||
|
||
const exec = util.promisify(require('child_process').exec); | ||
|
||
const tasks = [ | ||
{project: 'hermione', task: () => exec('npx hermione', {cwd: path.resolve(__dirname, 'hermione')})}, | ||
{project: 'plugins', task: async () => { | ||
const pluginNames = await fs.readdir('plugins'); | ||
await Promise.all(pluginNames.map(pluginName => | ||
exec('npm run build', {cwd: path.resolve(__dirname, 'hermione', pluginName)}) | ||
)); | ||
|
||
return exec('npx hermione', {cwd: path.resolve(__dirname, 'plugins')}); | ||
}} | ||
]; | ||
const allProjects = tasks.map(_.property('project')); | ||
|
||
(async () => { | ||
program | ||
.option('--all') | ||
.option('-p --project [value]', '') | ||
.parse(process.argv); | ||
|
||
let selectedProjects = []; | ||
if (program.all) { | ||
selectedProjects = allProjects; | ||
} else if (program.project) { | ||
selectedProjects = program.project; | ||
} else { | ||
const {projects} = await inquirer.prompt([{ | ||
type: 'checkbox', | ||
name: 'projects', | ||
message: 'Select projects for which you want to generate fixture reports:', | ||
choices: allProjects | ||
}]); | ||
|
||
selectedProjects = projects; | ||
} | ||
|
||
if (selectedProjects.some(p => !allProjects.includes(p))) { | ||
throw new Error(`Project must be one of ${allProjects}`); | ||
} | ||
|
||
await Promise.all(tasks | ||
.filter(task => selectedProjects.includes(task.project)) | ||
.map(task => task.task())); | ||
|
||
console.log('All done!'); | ||
})(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
const {GRID_URL, CHROME_BINARY_PATH} = require('../../utils/constants'); | ||
global.assert = require('chai').assert; | ||
|
||
const serverPort = 8080; | ||
const fixturesPath = 'test/func/fixtures/hermione/report'; | ||
|
||
module.exports = { | ||
gridUrl: GRID_URL, | ||
baseUrl: `http://localhost:${serverPort}/test/func/fixtures/hermione/index.html`, | ||
|
||
screenshotsDir: 'test/func/fixtures/screens', | ||
|
||
sets: { | ||
fixtures: { | ||
files: 'test/func/fixtures/**/*.hermione.js' | ||
} | ||
}, | ||
|
||
browsers: { | ||
chrome: { | ||
windowSize: '1280x1024', | ||
desiredCapabilities: { | ||
browserName: 'chrome', | ||
'goog:chromeOptions': { | ||
args: ['headless', 'no-sandbox'], | ||
binary: CHROME_BINARY_PATH, | ||
} | ||
} | ||
} | ||
}, | ||
|
||
plugins: { | ||
'html-reporter-test-server': { | ||
enabled: true, | ||
port: serverPort | ||
}, | ||
'html-reporter-tester': { | ||
enabled: true, | ||
path: fixturesPath, | ||
}, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
describe('failed describe', function() { | ||
it('successfully passed test', async function() { | ||
await this.browser.url(this.browser.options.baseUrl); | ||
|
||
assert.isTrue(true); | ||
}); | ||
|
||
it('test without screenshot', async function() { | ||
await this.browser.url(this.browser.options.baseUrl); | ||
|
||
await this.browser.assertView('header', 'header'); | ||
}); | ||
|
||
it('test with long error message', async function() { | ||
throw new Error(`long_error_message ${'0123456789'.repeat(20)}\n message content`); | ||
}); | ||
}); |
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
describe('success describe', function() { | ||
it('succesfully passed test', async function() { | ||
await this.browser.url(this.browser.options.baseUrl); | ||
|
||
assert.isTrue(true); | ||
}); | ||
|
||
it('test with screenshot', async function() { | ||
await this.browser.url(this.browser.options.baseUrl); | ||
|
||
await this.browser.assertView('header', 'header'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.