Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
Adds scaffolding for e2e tests (At this time Firefox only)
Browse files Browse the repository at this point in the history
  • Loading branch information
FoseFx committed Oct 21, 2019
1 parent aa7ced5 commit 24de136
Show file tree
Hide file tree
Showing 10 changed files with 493 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ branches:
language: node_js
node_js:
- 10
addons:
firefox: latest-dev
before_script:
- "npm run setup"
script:
- "npm run lint"
- "npm run test"
- "npm run e2e"
- "npm run build:prod"
after_script:
- "bash <(curl -s https://codecov.io/bash) -t $(echo $UPLOAD_TOKEN)"
- "bash <(curl -s https://codecov.io/bash) -t $(echo $UPLOAD_TOKEN)"
10 changes: 10 additions & 0 deletions build/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const run = require('./run');


(async () => {
await run('npm run build:dev');
process.chdir('dist');
await run('zip -r addon.xpi *');
process.chdir('../');
await run('npx jest --config jest.e2e.config.js');
})();
16 changes: 16 additions & 0 deletions e2e/beforeEachE2E.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const path = require('path');
const webdriver = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');

export default function beforeEachE2E() {
const ffOptions = new firefox.Options()
.headless()
.setPreference('xpinstall.signatures.required', false)
.setPreference('xpinstall.whitelist.required', false)
.addExtensions(path.join(__dirname, '../dist/addon.xpi'));

return new webdriver.Builder()
.forBrowser('firefox')
.setFirefoxOptions(ffOptions)
.build();
}
3 changes: 3 additions & 0 deletions e2e/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file gets executed after jest
// has started, see ../jest.e2e.conf.js
jest.setTimeout(30000); // 30s
12 changes: 12 additions & 0 deletions e2e/tests/sampleTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import beforeEachE2E from '../beforeEachE2E';

describe('SampleTest Suite', function() {
let driver: any;

beforeEach(() => driver = beforeEachE2E());

it('should run the test', async () => {
await driver.get('https://www.faceit.com');
await driver.quit();
});
});
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ module.exports = {
"tsConfig": "tsconfig.content_scripts.dev.json"
}
}
}
};
16 changes: 16 additions & 0 deletions jest.e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
"roots": [
"<rootDir>/e2e/tests",
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"globals": {
"ts-jest": {
"tsConfig": "tsconfig.content_scripts.dev.json"
}
},
"setupFilesAfterEnv": [
"<rootDir>/e2e/init.ts",
],
};
8 changes: 7 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,11 @@
],
"background": {
"scripts": ["browser-polyfill.min.js", "background/msg_broker.js"]
},
"browser_specific_settings": {
"gecko": {
"id": "ecl-report-addon@fosefx.com",
"strict_min_version": "42.0"
}
}
}
}
Loading

0 comments on commit 24de136

Please sign in to comment.