diff --git a/.github/workflows/e2-tests.yml b/.github/workflows/e2-tests.yml new file mode 100644 index 0000000..ee49096 --- /dev/null +++ b/.github/workflows/e2-tests.yml @@ -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 "github-cd-bot@example.com" + - 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 }} diff --git a/.gitignore b/.gitignore index 9d3a14b..3b2b76d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,8 @@ yarn-error.log* /dist_electron package-lock.json + + +test/e2e/node_modules +test/e2e/yarn.lock +test/e2e/output diff --git a/test/e2e/codecept.conf.ts b/test/e2e/codecept.conf.ts new file mode 100644 index 0000000..e53e30a --- /dev/null +++ b/test/e2e/codecept.conf.ts @@ -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' +} diff --git a/test/e2e/homepage_test.ts b/test/e2e/homepage_test.ts new file mode 100644 index 0000000..3ae8888 --- /dev/null +++ b/test/e2e/homepage_test.ts @@ -0,0 +1,10 @@ +const { I } = inject(); + +Feature('homepage'); + + +Scenario('Home page is loaded', () => { + I.amOnPage(''); + I.waitForText('Write a Test'); +}); + diff --git a/test/e2e/package.json b/test/e2e/package.json new file mode 100644 index 0000000..f896a74 --- /dev/null +++ b/test/e2e/package.json @@ -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" + } +} diff --git a/test/e2e/steps.d.ts b/test/e2e/steps.d.ts new file mode 100644 index 0000000..49d8f0f --- /dev/null +++ b/test/e2e/steps.d.ts @@ -0,0 +1,11 @@ +/// +type steps_file = typeof import('./steps_file'); + +declare namespace CodeceptJS { + interface SupportObject { I: I, current: any } + interface Methods extends Playwright {} + interface I extends ReturnType {} + namespace Translation { + interface Actions {} + } +} diff --git a/test/e2e/steps_file.ts b/test/e2e/steps_file.ts new file mode 100644 index 0000000..1083a85 --- /dev/null +++ b/test/e2e/steps_file.ts @@ -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. + + }); +} diff --git a/test/e2e/tsconfig.json b/test/e2e/tsconfig.json new file mode 100644 index 0000000..a4a3e5f --- /dev/null +++ b/test/e2e/tsconfig.json @@ -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"] +} \ No newline at end of file