diff --git a/.github/workflows/e2e-manual.yml b/.github/workflows/e2e-manual.yml deleted file mode 100644 index f4c352cd8..000000000 --- a/.github/workflows/e2e-manual.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: E2E Manual Test - -on: - workflow_dispatch: - inputs: - branch: - description: 'Branch to checkout' - required: true - default: 'main' - cliArgs: - description: 'Additional CLI arguments' - required: true - default: '--format=json' - -jobs: - build-and-test: - runs-on: ubuntu-22.04 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.branch }} - - - 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: Build UI5 Linter - run: npm run build - - - name: Run tests against sample project - run: cd test/fixtures/linter/projects/com.ui5.troublesome.app && ../../../../../bin/ui5lint.js ${{ github.event.inputs.cliArgs }} > ../../../../../ui5lint-e2e-results.json 2>&1 || true - - - name: Compare results - run: npm run ci:e2e diff --git a/.github/workflows/e2e-pr.yml b/.github/workflows/e2e-pr.yml deleted file mode 100644 index c0414618b..000000000 --- a/.github/workflows/e2e-pr.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: E2E Automatic Test - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - build-and-test: - 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: Build UI5 Linter - run: npm run build - - - name: Run tests against sample project - run: cd test/fixtures/linter/projects/com.ui5.troublesome.app && ../../../../../bin/ui5lint.js --format=json > ../../../../../ui5lint-e2e-results.json 2>&1 || true - - - name: Compare results - run: npm run ci:e2e diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 000000000..68cca4024 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,28 @@ +name: e2e 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 diff --git a/.gitignore b/.gitignore index 719f74940..829cb1fe0 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,4 @@ dist # Temporary files /tmp/ +/test/tmp/ diff --git a/ava-e2e-ci.config.js b/ava-e2e-ci.config.js deleted file mode 100644 index 0867a177e..000000000 --- a/ava-e2e-ci.config.js +++ /dev/null @@ -1,5 +0,0 @@ -import defaultAvaConfig from "./ava.config.js"; - -defaultAvaConfig.files = ["test/e2e/ci-compare.ts"]; - -export default defaultAvaConfig; diff --git a/ava-e2e.config.js b/ava-e2e.config.js index 80dd0854d..ee9c89b43 100644 --- a/ava-e2e.config.js +++ b/ava-e2e.config.js @@ -2,7 +2,6 @@ import defaultAvaConfig from "./ava.config.js"; defaultAvaConfig.files = [ "test/e2e/**/*.ts", - "!test/e2e/ci-compare.ts", ]; export default defaultAvaConfig; diff --git a/eslint.config.js b/eslint.config.js index 2698ac7e3..486f59da0 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -19,11 +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", - "test/e2e/ci-compare.ts", // Exclude generated code "lib/*", @@ -59,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, @@ -129,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", + ], + }], }, } ); diff --git a/package.json b/package.json index f8efee3ad..057baef90 100644 --- a/package.json +++ b/package.json @@ -34,17 +34,19 @@ "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", "lint": "eslint .", "lint:commit": "commitlint -e", "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", + "test": "npm run lint && npm run build-test && npm run coverage && npm run depcheck && npm run check-licenses", "unit": "ava", - "e2e": "npm run build && ava --config ava-e2e.config.js", - "ci:e2e": "ava --config ava-e2e-ci.config.js", - "ci:e2e-update-snapshots": "ava --config ava-e2e-ci.config.js --update-snapshots", + "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 && 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", diff --git a/test/e2e/ci-compare.ts b/test/e2e/ci-compare.ts deleted file mode 100644 index f8af66501..000000000 --- a/test/e2e/ci-compare.ts +++ /dev/null @@ -1,11 +0,0 @@ -import test from "ava"; -import {createRequire} from "node:module"; - -// Using CommonsJS require since JSON module imports are still experimental -const require = createRequire(import.meta.url); - -test.serial("Compare snapshots", (t) => { - const results = require("../../ui5lint-e2e-results.json"); - - t.snapshot(results); -}); diff --git a/test/e2e/compare-snapshots.ts b/test/e2e/compare-snapshots.ts new file mode 100644 index 000000000..185023850 --- /dev/null +++ b/test/e2e/compare-snapshots.ts @@ -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); +}); diff --git a/test/e2e/snapshots/ci-compare.ts.snap b/test/e2e/snapshots/ci-compare.ts.snap deleted file mode 100644 index 30d7e1e21..000000000 Binary files a/test/e2e/snapshots/ci-compare.ts.snap and /dev/null differ diff --git a/test/e2e/snapshots/ci-compare.ts.md b/test/e2e/snapshots/compare-snapshots.ts.md similarity index 99% rename from test/e2e/snapshots/ci-compare.ts.md rename to test/e2e/snapshots/compare-snapshots.ts.md index a90e247d7..c82730689 100644 --- a/test/e2e/snapshots/ci-compare.ts.md +++ b/test/e2e/snapshots/compare-snapshots.ts.md @@ -1,13 +1,17 @@ -# Snapshot report for `test/e2e/ci-compare.ts` +# Snapshot report for `test/e2e/compare-snapshots.ts` -The actual snapshot is saved in `ci-compare.ts.snap`. +The actual snapshot is saved in `compare-snapshots.ts.snap`. Generated by [AVA](https://avajs.dev). -## Compare snapshots +## Compare com.ui5.troublesome.app result snapshots > Snapshot 1 + '' + +> Snapshot 2 + [ { errorCount: 3, diff --git a/test/e2e/snapshots/compare-snapshots.ts.snap b/test/e2e/snapshots/compare-snapshots.ts.snap new file mode 100644 index 000000000..d4a85cde7 Binary files /dev/null and b/test/e2e/snapshots/compare-snapshots.ts.snap differ