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

test: Add e2e test workflow #536

Merged
merged 16 commits into from
Feb 19, 2025
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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,3 @@ jobs:

- name: Send report to Coveralls for package @ui5/linter
uses: coverallsapp/github-action@v2.3.6

- name: Run e2e tests
run: npm run e2e
28 changes: 28 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: End-To-End Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
e2e:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js 20.11.0
uses: actions/setup-node@v4.0.2
with:
node-version: 20.11.0

- name: Install dependencies
run: npm ci

- name: Run e2e tests
run: npm run e2e
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ dist

# Temporary files
/tmp/
/test/tmp/
18 changes: 14 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export default tseslint.config(
"test/tmp/*",
"test/projects/*",
"test/fixtures/*",
// This file must be excluded as it tests the package exports by
// requiring the package itself, which causes a circular dependency
// and TypeScript/ESlint gets confused during compilation.
"test/e2e/package-exports.ts",

// Exclude generated code
"lib/*",
Expand Down Expand Up @@ -58,6 +54,12 @@ export default tseslint.config(
// This file is a copy of an openui5 resource which is located at
// https://github.com/SAP/openui5/blob/master/lib/jsdoc/transformApiJson.js
"src/formatter/lib/resolveLinks.ts",

// This file must be excluded as it tests the package exports by
// requiring the package itself, which causes a circular dependency
// and TypeScript/ESlint gets confused during compilation.
"test/e2e/package-exports.ts",

],
languageOptions: {
ecmaVersion: 2022,
Expand Down Expand Up @@ -128,6 +130,14 @@ export default tseslint.config(
],
"no-console": "error",
"no-eval": "error",
"ava/no-ignored-test-files": ["error", {
files: [
"test/lib/**/*.ts",
// This additional entry is needed as the rule otherwise complains about
// ignored test files. The files are configured in a separate ava config.
"test/e2e/**/*.ts",
],
}],
},
}
);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"check-licenses": "licensee --errors-only",
"clean-coverage": "rimraf coverage",
"clean-lib": "rimraf lib",
"clean-test-tmp": "rimraf test/tmp",
"coverage": "npm run clean-coverage && nyc ava --node-arguments=\"--experimental-loader=@istanbuljs/esm-loader-hook\"",
"depcheck": "depcheck --ignores @commitlint/config-conventional,@istanbuljs/esm-loader-hook,rimraf,sap,mycomp,@ui5/linter",
"hooks:pre-push": "npm run lint:commit",
Expand All @@ -42,7 +43,10 @@
"prepare": "node ./.husky/skip.js || husky",
"test": "npm run lint && npm run build-test && npm run coverage && npm run e2e && npm run depcheck && npm run check-licenses",
"unit": "ava",
"e2e": "npm run build && ava --config ava-e2e.config.js",
"e2e": "npm run build && npm run e2e:ui5lint && npm run e2e:test",
"e2e:ui5lint": "TEST_E2E_TMP=$PWD/test/tmp/e2e && npm run clean-test-tmp && mkdir -p $TEST_E2E_TMP && cd test/fixtures/linter/projects/com.ui5.troublesome.app && npm exec ui5lint -- --format=json > $TEST_E2E_TMP/ui5lint-results.json 2> $TEST_E2E_TMP/stderr.log || true",
"e2e:test": "ava --config ava-e2e.config.js",
"e2e:test-update-snapshots": "ava --config ava-e2e.config.js --update-snapshots",
"unit-debug": "ava debug",
"unit-update-snapshots": "ava --update-snapshots",
"unit-watch": "ava --watch",
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/compare-snapshots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import test from "ava";
import {readFile} from "node:fs/promises";

const E2E_DIR_URL = new URL("../tmp/e2e/", import.meta.url);

test.serial("Compare com.ui5.troublesome.app result snapshots", async (t) => {
const stderr = await readFile(new URL("stderr.log", E2E_DIR_URL), {encoding: "utf-8"});
t.snapshot(stderr);
const results = JSON.parse(await readFile(new URL("ui5lint-results.json", E2E_DIR_URL), {encoding: "utf-8"}));
t.snapshot(results);
});
Loading