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

Validate test implementation in validate-test #809

Merged
merged 14 commits into from
Feb 8, 2021
Merged

Conversation

dagda1
Copy link
Contributor

@dagda1 dagda1 commented Feb 2, 2021

In response to #801 where a malformed test file resulted in a meaningless error message.

This PR verifies (in validate-test) that a test object must have

  • At the very least a description filed
  • assertions and children fields.

Descriptive errors are thrown if either of the above is not true.

@dagda1 dagda1 requested a review from cowboyd February 2, 2021 17:42
@changeset-bot
Copy link

changeset-bot bot commented Feb 2, 2021

🦋 Changeset detected

Latest commit: 6434917

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@bigtest/suite Patch
bigtest Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2021

A preview package of this pull request has been published with the tag validate-test-object.
You can try it out by running the following command:

$ npm install @bigtest/suite@validate-test-object

or by updating your package.json to:

{
  "@bigtest/suite": "validate-test-object"
}

Generated by 🚫 dangerJS against 6434917

@dagda1 dagda1 force-pushed the validate-test-object branch from 74446f8 to 8ffcba2 Compare February 4, 2021 07:59
@dagda1 dagda1 requested a review from jnicklas February 4, 2021 08:03
@dagda1 dagda1 force-pushed the validate-test-object branch from 8ffcba2 to cf2c980 Compare February 4, 2021 21:02
@dagda1 dagda1 requested a review from jnicklas February 4, 2021 21:19
@dagda1 dagda1 force-pushed the validate-test-object branch from 69ea1c3 to 61294a8 Compare February 5, 2021 08:06
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function ensureIsTest (test: any, path: string[] = [], file?: string): test is Test {
if(!test) {
throw new TestValidationError("contains no description.\n\nDoes the test file contain a default export?", path, file)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this error message should not mention description?

}

if(!test?.children || !test?.assertions) {
throw new TestValidationError('contains no assertions or children.');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have these as separate, more specific errors?

@dagda1 dagda1 requested a review from jnicklas February 5, 2021 17:55
@jnicklas
Copy link
Collaborator

jnicklas commented Feb 8, 2021

The CI build should be fixed now, could you rebase this?

@dagda1 dagda1 force-pushed the validate-test-object branch from 9f93ac5 to caa935a Compare February 8, 2021 19:07
@dagda1 dagda1 merged commit 0dacf30 into v0 Feb 8, 2021
@dagda1 dagda1 deleted the validate-test-object branch February 8, 2021 19:41
@dagda1
Copy link
Contributor Author

dagda1 commented Feb 8, 2021

The CI build should be fixed now, could you rebase this?

rebased and gone!

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.

2 participants