Skip to content

Commit

Permalink
feat(ci) Add e2e tests to CI (botpress#2425)
Browse files Browse the repository at this point in the history
* Rework e2e tests

* wip

* All tests pass

* Prettier

* Fix Load server license page test

* Run only 3 test runs

* Revert

* Make rollback revision test more reliable

* More debugging

* Find element

* Merge (1)

* Reintroduce all 5 test suites

* frame navigated event

* Increase timeout

* Cleanup

* closeToaster

* Fix

* Close toaster

* Prettier

* Code style

* Yarn verbose

* Change test order

* Code style

* Remove logging

* Remove logging

* Dead code

* Remove logging

* Fix for test: Load debugging page

* Prettier

* yn
  • Loading branch information
spg authored Oct 10, 2019
1 parent 35aef83 commit 8924323
Show file tree
Hide file tree
Showing 21 changed files with 705 additions and 58 deletions.
130 changes: 130 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,133 @@ jobs:
- name: Run tests
run: |
docker-compose up --exit-code-from botpress
e2e_1:
name: e2e (1)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '10.11.0'
- name: Fetch Node Packages
run: |
yarn --verbose
- name: Build core, UI and modules
run: |
NODE_OPTIONS="--max-old-space-size=6000" yarn build
- name: Run Tests
run: |
yarn start &
HEADLESS=true JEST_TIMEOUT=30000 yarn itest
- name: Upload Screenshots
uses: actions/upload-artifact@master
if: failure()
with:
name: screenshots1
path: build/tests/e2e/screenshots

e2e_2:
name: e2e (2)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '10.11.0'
- name: Fetch Node Packages
run: |
yarn --verbose
- name: Build core, UI and modules
run: |
NODE_OPTIONS="--max-old-space-size=6000" yarn build
- name: Run Tests
run: |
yarn start &
HEADLESS=true JEST_TIMEOUT=30000 yarn itest
- name: Upload Screenshots
uses: actions/upload-artifact@master
if: failure()
with:
name: screenshots2
path: build/tests/e2e/screenshots

e2e_3:
name: e2e (3)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '10.11.0'
- name: Fetch Node Packages
run: |
yarn --verbose
- name: Build core, UI and modules
run: |
NODE_OPTIONS="--max-old-space-size=6000" yarn build
- name: Run Tests
run: |
yarn start &
HEADLESS=true JEST_TIMEOUT=30000 yarn itest
- name: Upload Screenshots
uses: actions/upload-artifact@master
if: failure()
with:
name: screenshots3
path: build/tests/e2e/screenshots

e2e_4:
name: e2e (4)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '10.11.0'
- name: Fetch Node Packages
run: |
yarn --verbose
- name: Build core, UI and modules
run: |
NODE_OPTIONS="--max-old-space-size=6000" yarn build
- name: Run Tests
run: |
yarn start &
HEADLESS=true JEST_TIMEOUT=30000 yarn itest
- name: Upload Screenshots
uses: actions/upload-artifact@master
if: failure()
with:
name: screenshots4
path: build/tests/e2e/screenshots

e2e_5:
name: e2e (5)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '10.11.0'
- name: Fetch Node Packages
run: |
yarn --verbose
- name: Build core, UI and modules
run: |
NODE_OPTIONS="--max-old-space-size=6000" yarn build
- name: Run Tests
run: |
yarn start &
HEADLESS=true JEST_TIMEOUT=30000 yarn itest
- name: Upload Screenshots
uses: actions/upload-artifact@master
if: failure()
with:
name: screenshots5
path: build/tests/e2e/screenshots
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ metadata.json
edition.json
/pro

build/tests/e2e/screenshots/*
!build/tests/e2e/screenshots/.gitkeep

# Botpress docs
/docs/reference/public
/docs/guide/build
Expand All @@ -54,4 +57,4 @@ edition.json
.python-version
/internal-modules
/private-modules
/src/bp/ml/node-svm
/src/bp/ml/node-svm
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@
"sourceMaps": true,
"autoAttachChildProcesses": true
},
{
"type": "node",
"request": "launch",
"name": "Debug Jest Integration Tests",
"cwd": "${workspaceFolder}",
"env": { "NATIVE_EXTENSIONS_DIR": "./build/native-extensions", "JEST_TIMEOUT": "30000" },
"args": [
"--inspect-brk",
"${workspaceFolder}/node_modules/.bin/jest",
"--runInBand",
"--detectOpenHandles",
"-c",
"jest.e2e.config.js",
"all"
],
"windows": {
"args": ["--inspect-brk", "${workspaceRoot}/node_modules/jest/bin/jest.js", "--runInBand"]
},
"outFiles": ["${workspaceFolder}/out/"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true,
"autoAttachChildProcesses": true
},
{
"name": "(lldb) Launch",
"type": "lldb",
Expand Down
Empty file.
8 changes: 5 additions & 3 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const yn = require('yn')

const windowSize = {
width: 1300,
height: 900
}

module.exports = {
launch: {
headless: false,
headless: yn(process.env.HEADLESS),
// +20 so it's a bit bigger than the viewport so nothing is cut
args: [`--window-size=${windowSize.width + 20},${windowSize.height + 20}`]
// slowMo: 40 // Set this value to slow down tests globally
args: [`--window-size=${windowSize.width + 20},${windowSize.height + 20}`],
slowMo: 40 // Set this value to slow down tests globally
// devtools: true // Access the dev tools on the headless chrome
},
bpConfig: {
Expand Down
7 changes: 4 additions & 3 deletions jest.e2e.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
}
},
globalSetup: 'jest-environment-puppeteer/setup',
setupFilesAfterEnv: ['expect-puppeteer'],
setupFilesAfterEnv: ['expect-puppeteer', './jest.setup.js'],
collectCoverage: false,
resetModules: true,
modulePaths: ['<rootDir>/src/bp/'],
Expand All @@ -17,7 +17,8 @@ module.exports = {
},
testMatch: ['**/src/e2e/**/*.test.(ts|js)'],
testPathIgnorePatterns: ['out', 'build', 'node_modules', 'src/bp'],
testEnvironment: 'jest-environment-puppeteer',
testEnvironment: '<rootDir>/src/e2e/customEnvironment.js',
rootDir: '.',
testResultsProcessor: './node_modules/jest-html-reporter'
testResultsProcessor: './node_modules/jest-html-reporter',
testRunner: "jest-circus/runner",
}
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest.setTimeout(process.env.JEST_TIMEOUT || 10000)
3 changes: 2 additions & 1 deletion modules/basic-skills/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"resolutions": {
"fstream": ">=1.0.12",
"lodash": ">=4.17.12"
"lodash": ">=4.17.12",
"react-tag-input/react-dnd": "^5.0.0"
}
}
Loading

0 comments on commit 8924323

Please sign in to comment.