Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: e2e tests ci/cd #250

Merged
merged 12 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/e2-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This to verify lib version bump doesn't break anything
name: E2E Tests

on:
push:
branches:
- master
- main
pull_request:
branches:
- '**'

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: git config --global user.name "GitHub CD bot"
- run: git config --global user.email "[email protected]"
- name: Install deps
run: npm i -g wait-for-localhost-cli && npm i
- name: Start app and run tests
run: npm run serve & wait-for-localhost 8080; cd test/e2e; npm i && npx playwright install chromium && npm run test
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ yarn-error.log*
/dist_electron

package-lock.json


test/e2e/node_modules
test/e2e/yarn.lock
test/e2e/output
18 changes: 18 additions & 0 deletions test/e2e/codecept.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const config: CodeceptJS.MainConfig = {
tests: './*_test.ts',
output: './output',
helpers: {
Playwright: {
browser: 'chromium',
url: 'http://localhost:8080',
show: false,
timeout: 10000,
waitForNavigation: 'load',
waitForTimeout: 10000
}
},
include: {
I: './steps_file'
},
name: 'e2e'
}
10 changes: 10 additions & 0 deletions test/e2e/homepage_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { I } = inject();

Feature('homepage');


Scenario('Home page is loaded', () => {
I.amOnPage('');
I.waitForText('Write a Test');
});

20 changes: 20 additions & 0 deletions test/e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "e2e",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "npx codeceptjs run --verbose"
},
"author": "",
"license": "ISC",
"dependencies": {
"codeceptjs": "^3.5.14",
"playwright": "^1.41.2"
},
"devDependencies": {
"@types/node": "20.11.20",
"ts-node": "10.9.2",
"typescript": "5.3.3"
}
}
11 changes: 11 additions & 0 deletions test/e2e/steps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types='codeceptjs' />
type steps_file = typeof import('./steps_file');

declare namespace CodeceptJS {
interface SupportObject { I: I, current: any }
interface Methods extends Playwright {}
interface I extends ReturnType<steps_file> {}
namespace Translation {
interface Actions {}
}
}
10 changes: 10 additions & 0 deletions test/e2e/steps_file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// in this file you can append custom step methods to 'I' object

export = function() {
return actor({

// Define custom steps here, use 'this' to access default methods of I.
// It is recommended to place a general 'login' function here.

});
}
16 changes: 16 additions & 0 deletions test/e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"ts-node": {
"files": true
},
"compilerOptions": {
"target": "es2018",
"lib": ["es2018", "DOM"],
"esModuleInterop": true,
"module": "commonjs",
"strictNullChecks": false,
"types": ["codeceptjs", "node"],
"declaration": true,
"skipLibCheck": true
},
"exclude": ["node_modules"]
}
Loading