Skip to content

test(sdk): await rejects assertions in loadSourceConfig - #3318

Closed
rajanpanth wants to merge 1 commit into
evidence-dev:mainfrom
rajanpanth:test/await-rejects-assertions
Closed

test(sdk): await rejects assertions in loadSourceConfig#3318
rajanpanth wants to merge 1 commit into
evidence-dev:mainfrom
rajanpanth:test/await-rejects-assertions

Conversation

@rajanpanth

Copy link
Copy Markdown

Three tests in loadSourceConfig.spec.js assert on a rejected promise without awaiting it:

expect(loadConnection('./sources/invalidYaml')).rejects.toThrowError(
  'Error parsing connection.yaml file'
);

The assertion is never awaited, so it does not run before the test ends. All three tests are named "should throw …" and none of them can currently fail. Vitest already flags it when the suite runs:

Promise returned by expect(actual).rejects.toThrowError(expected) was not awaited. Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3.

So this is also forward-breaking, not just dead coverage.

The neighbouring tests in the same file already use await correctly (expect(await loadConnectionOptions(...)).toEqual(...)), so this looks like an oversight rather than intent.

Verification. All 13 tests in the file pass with the awaits added, and the three Vitest warnings are gone. To confirm the assertions are now actually live, I changed one expected message to a string that cannot match and re-ran: that test failed, as it should. Before the change, the same mutation still passed. Reverted afterwards.

I scanned the rest of the repo for the same pattern and this file was the only occurrence. prettier --check passes on the changed file.

Three tests asserted on rejection without awaiting, so the assertions
never ran and the tests could not fail. Vitest already warns that this
breaks in Vitest 3.
@rajanpanth
rajanpanth requested a deployment to Approval required to run action on external PR August 20, 2026 01:23 — with GitHub Actions Waiting
@rajanpanth

Copy link
Copy Markdown
Author

Closing this: the restructure superseded it.

packages/lib/sdk/src/plugins/datasources/loadSourceConfig.spec.js was removed, and there is no plugins/datasources directory in the new layout, so the unawaited rejects assertions this PR fixed no longer exist.

The 505885dad publish evidence core restructure replaced packages/ with cli/, core/ and docs/, so this branch no longer applies and there is nothing left to rebase onto.

@rajanpanth rajanpanth closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant