avajs/ava

Implement .because() modifier for irregular tests

Open

#3227 aperta il 30 lug 2023

Vedi su GitHub
 (14 commenti) (0 reazioni) (0 assegnatari)JavaScript (1408 fork)batch import
enhancementhelp wantedscope:test-interface

Metriche repository

Star
 (20.600 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Based on discussion with @tommy-mitchell in https://github.com/avajs/ava/discussions/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.

Guida contributor