Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Testing your Application: explain why interdependent tests are bad

未关闭 适合新手
#683 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 7 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
停滞
技术栈
typescript
领域
documentation

调研方向

先从 issue 中链接的“Data Handling in Testing your Application”部分开始,然后阅读所引用的示例测试和 pull request 讨论,以了解背景。更新文档,解释相互依赖的测试为何存在问题,以及独立测试如何支持隔离执行;完成的标准是同时涵盖失败级联和 it.only()/mocha -g 的使用。

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

描述

Docs good first issue help wanted

In https://github.com/strongloop/loopback4-example-getting-started/pull/2, the proposed acceptance tests are relying on the first test to fill the database with data that's used by subsequent tests:

  it('creates a todo', async () => {
    item = (await client
      .post('/todo')
      .send(payload)
      .expect(
        Object.assign({}, payload, {
          id: 1
        })
      )).body;
  });

  //...

  it('successfully deletes todos', async () => {
    await client.del(`/todo/${item.id}`).send();
    await client
      .get(`/todo/${item.id}`)
      .send()
      .expect(404);
  });

(see https://github.com/strongloop/loopback4-example-getting-started/pull/2#discussion_r147389550)

This is an anti-pattern to avoid:

  • if the first test fails, all subsequent tests fail too (because data was not filled in), but with an unhelpful error message is confusing.
  • it is not possible to run individual tests on their own, e.g. via it.only() or mocha -g "test name".

We should extend Data Handling in Testing your Application to mention this pattern and explain why it's a bad thing to do.

主要语言
TypeScript
星标
5.1k
派生
1.1k
平均合并
2 天 16 小时
30 天内合并 PR
31

环境准备

从这里开始

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

loopbackio/loopback-next 的其他 Issue

查看 loopbackio/loopback-next 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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