nodejs / nodejs/node

test runner (--test, node:test) subtest test context lack `.skip`, `.only` and `.todo` functions

未关闭
#50,665 6 条评论 5 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

confirmed-bug test_runner
主要语言
JavaScript
星标
122k
派生
37.3k
平均合并
4 天 2 小时
30 天内合并 PR
283

描述

Version

20.7.0

Platform

Linux void-desktop 6.5.9_1 #1 SMP PREEMPT_DYNAMIC Thu Oct 26 12:11:50 UTC 2023 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?
const test = require('node:test');

test('Parent', t => {
	t.test.only('Child only', () => {});
	t.test.skip('Child skip', () => {});
	t.test.todo('Child todo', () => {});
});

Run with node --test <file> (same result without the --test flag)

How often does it reproduce? Is there a required condition?

Consistently

What is the expected behavior? Why is that the expected behavior?

All functions work as described here: https://nodejs.org/docs/latest-v20.x/api/test.html#subtests

This method behaves identically to the top level test() function. The following example demonstrates the creation of a top level test with two subtests.

What do you see instead?
TypeError [Error]: t.test.todo is not a function
TypeError [Error]: t.test.skip is not a function
TypeError [Error]: t.test.only is not a function
Additional information

These functions work for top-level test, they don't work for nested tests.
Maybe it doesn't make sense to expose those functions for subtests (use just describe - maybe it's enough), but in that case the documentation is misleading

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 node:test 子测试 API 入口开始,使用 node --test 或不使用该标志复现所提供的嵌套测试。将 t.test.only、t.test.skip 和 t.test.todo 的文档行为与观察到的 TypeErrors 进行比较;当嵌套 API 的行为与文档对预期行为达成一致时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
testing
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。