Skip to content

Implement .because() modifier for irregular tests #3227

Open
@novemberborn

Description

@novemberborn

Based on discussion with @tommy-mitchell in #3224:

test.failing('does foo', t => {
  // ..
}).because('waiting on some/repo#123')

Should output:

✔ [expected fail] does foo
  - waiting on some/repo#123

This requires changes to https://github.com/avajs/ava/blob/main/lib/create-chain.js so that a chainable object is returned for test.failing(), test.skip() etc. Here we then need to add a because function. The reason should make its way to the reporter where it can be printed beneath the test title.

This should be reflected in the type definitions and documentation. Once we've made some progress on this, work needs to be done with https://github.com/avajs/eslint-plugin-ava to support this new modifier.

It should be a test failure if because() is called with anything but a non-empty string.

Activity

sindresorhus

sindresorhus commented on Jul 30, 2023

@sindresorhus
novemberborn

novemberborn commented on Jul 30, 2023

@novemberborn
Author
tommy-mitchell

tommy-mitchell commented on Jul 30, 2023

@tommy-mitchell
Contributor

This could have an ESLint rule as well, requiring a .because() description

tommy-mitchell

tommy-mitchell commented on Jul 31, 2023

@tommy-mitchell
novemberborn

novemberborn commented on Aug 15, 2023

@novemberborn
Author
adiSuper94

adiSuper94 commented on Sep 18, 2023

@adiSuper94
Contributor

@novemberborn If no one has started working on the implementation, I'd like to take a crack at this.

adiSuper94

adiSuper94 commented on Sep 29, 2023

@adiSuper94
Contributor

Turned out to more complex than I anticipated. But I am still working on this.

adiSuper94

adiSuper94 commented on Sep 30, 2023

@adiSuper94
Contributor

@novemberborn I have made some test and trying to test it. But looks like when I run npm run test it calls the old version of create-chain.js instead of the new version that I have made edits to. Is this an issue you have ever faced ??

novemberborn

novemberborn commented on Oct 12, 2023

@novemberborn
MemberAuthor

npm test calls npx test-ava which uses a different copy of AVA to test AVA with. But these tests are meant to be integration style, so you'd set up a fixture which uses the new syntax and then you observe the behavior.

adiSuper94

adiSuper94 commented on Dec 22, 2023

@adiSuper94
Contributor

I haven't worked on this for a while now. And I am facing troubles setting up the the test, so that the tests use the my changes. If some else has more experience doing I'd like some help, or they can take up the this issue entirely.

arescrimson

arescrimson commented on Jan 6, 2024

@arescrimson

@adiSuper94 , I can take up this issue if you want. In addition, what troubles were you having setting up the tests?

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @novemberborn@sindresorhus@tommy-mitchell@oantoro@adiSuper94

        Issue actions

          Implement .because() modifier for irregular tests · Issue #3227 · avajs/ava