From 2bc84dd65ebc2f837d93c3a88a5e0941f0b73388 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 6 Jun 2024 08:12:13 -0400 Subject: [PATCH] Separate unit and integration tests. Signed-off-by: dblock --- .github/workflows/test-tools.yml | 10 ++-------- DEVELOPER_GUIDE.md | 2 ++ package.json | 4 +++- tools/tests/tester/{ => integ}/StoryEvaluator.test.ts | 2 +- tools/tests/tester/{ => integ}/TestRunner.test.ts | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) rename tools/tests/tester/{ => integ}/StoryEvaluator.test.ts (97%) rename tools/tests/tester/{ => integ}/TestRunner.test.ts (92%) diff --git a/.github/workflows/test-tools.yml b/.github/workflows/test-tools.yml index cdd7897f3..eed811e1d 100644 --- a/.github/workflows/test-tools.yml +++ b/.github/workflows/test-tools.yml @@ -46,11 +46,5 @@ jobs: - name: Lint run: npm run lint - - name: Test Spec Merger - run: npm run test -- tools/tests/merger - - - name: Test Spec Linter - run: npm run test -- tools/tests/linter - - - name: Test Spec Tester - run: npm run test -- tools/tests/tester --runInBand + - name: Tests + run: npm run test diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 65229fae4..d8efe265a 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -383,6 +383,8 @@ Specify the test path to run tests for one of the tools: npm run test -- tools/tests/tester/ ``` +The test suite contains unit tests and integration tests. Integration tests, such as [these](tools/tests/tester/integ/), require a local instance of OpenSearch and are placed into a folder named `integ`. Unit tests are run in parallel and integration tests are run sequentially using `--runInBand`. You can run unit tests with `npm run test:unit` separately from integration tests with `npm run test:integ`. + #### Lints All code is linted using [ESLint](https://eslint.org/) in combination with [typescript-eslint](https://typescript-eslint.io/). Linting can be run via: diff --git a/package.json b/package.json index 6e953726a..032861043 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "lint": "eslint .", "lint--fix": "eslint . --fix", "merge": "ts-node tools/src/merger/merge.ts", - "test": "jest", + "test": "npm run test:unit && npm run test:integ", + "test:unit": "jest --testMatch='**/*.test.ts' --testPathIgnorePatterns=/integ/", + "test:integ": "jest --testMatch='**/integ/*.test.ts' --runInBand", "test:spec": "ts-node tools/src/tester/start.ts" }, "dependencies": { diff --git a/tools/tests/tester/StoryEvaluator.test.ts b/tools/tests/tester/integ/StoryEvaluator.test.ts similarity index 97% rename from tools/tests/tester/StoryEvaluator.test.ts rename to tools/tests/tester/integ/StoryEvaluator.test.ts index 3edae05ea..bcb8959f4 100644 --- a/tools/tests/tester/StoryEvaluator.test.ts +++ b/tools/tests/tester/integ/StoryEvaluator.test.ts @@ -7,7 +7,7 @@ * compatible open source license. */ -import { construct_tester_components, load_actual_evaluation, load_expected_evaluation } from './helpers' +import { construct_tester_components, load_actual_evaluation, load_expected_evaluation } from '../helpers' const { story_evaluator } = construct_tester_components('tools/tests/tester/fixtures/specs/indices_excerpt.yaml') diff --git a/tools/tests/tester/TestRunner.test.ts b/tools/tests/tester/integ/TestRunner.test.ts similarity index 92% rename from tools/tests/tester/TestRunner.test.ts rename to tools/tests/tester/integ/TestRunner.test.ts index 00f3c47c3..b6c8c99f9 100644 --- a/tools/tests/tester/TestRunner.test.ts +++ b/tools/tests/tester/integ/TestRunner.test.ts @@ -7,8 +7,8 @@ * compatible open source license. */ -import { construct_tester_components, flatten_errors, load_expected_evaluation } from './helpers' -import { type StoryEvaluation } from '../../src/tester/types/eval.types' +import { construct_tester_components, flatten_errors, load_expected_evaluation } from '../helpers' +import { type StoryEvaluation } from '../../../src/tester/types/eval.types' test('stories folder', async () => { const { test_runner } = construct_tester_components('tools/tests/tester/fixtures/specs/indices_excerpt.yaml')