avajs/ava

Implement .because() modifier for irregular tests

Open

#3,227 建立於 2023年7月30日

在 GitHub 查看
 (14 留言) (0 反應) (0 負責人)JavaScript (20,600 star) (1,408 fork)batch import
enhancementhelp wantedscope:test-interface

描述

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.

貢獻者指南