Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Run tests only when they are detected on the disk. Do not run tests when the test file pattern is invalid. Require to set KNAPSACK_PRO_TEST_FILE_PATTERN #11

Merged
merged 2 commits into from
Nov 22, 2019

Conversation

ArturT
Copy link
Member

@ArturT ArturT commented Nov 21, 2019

Problem

When a user has test files in a non-standard directory then Knapsack Pro can't find test files so the empty array of tests is sent to Knapsack Pro API Queue. API returns an error so Knapsack Pro switches to Fallback Mode and runs the whole test suite on a single node because the empty list of tests was set for Jest CLI which means Jest should run all tests. It leads to all parallel CI nodes to run the whole test suite.

2019-11-21T22:30:08.075Z [@knapsack-pro/core] info: POST http://api.knapsackpro.test:3000/v1/queues/queue

2019-11-21T22:30:08.269Z [@knapsack-pro/core] error: 422 Unprocessable Entity

Request ID:
29b25da6-4811-48bb-9e14-b0d254bdb1e0

Response body:
{ errors: [ { test_files: [ 'parameter is required' ] } ] }

2019-11-21T22:30:08.269Z [@knapsack-pro/core] warn: Fallback Mode has started. We could not connect to Knapsack Pro API. Your tests will be executed based on test file names.

If other CI nodes were able to connect to Knapsack Pro API then you may notice that some of the test files were executed twice across CI nodes. Fallback Mode guarantees each of test files is run at least once as a part of CI build.
 PASS  __tests__/directory/c.test.js
 PASS  __tests__/b.spec.js
 PASS  __tests__/a.test.js

Test Suites: 3 passed, 3 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        5.577s
Ran all test suites within paths .

...

Solution

Thanks to this a user who has a test suite in a non-standard directory won't be accidentally running tests in Fallback Mode. Users will see meaningful error with tips on what to do to fix the problem.

Other changes

@ArturT ArturT added the enhancement New feature or request label Nov 21, 2019
@ArturT ArturT merged commit e2a4fe1 into master Nov 22, 2019
@ArturT ArturT deleted the detect-invalid-test-file-pattern branch November 22, 2019 12:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant