Testing your Application: explain why interdependent tests are bad
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- documentation
Research direction
Start with the Data Handling in Testing your Application section linked in the issue, then read the referenced example tests and pull request discussion for context. Update the documentation to explain why interdependent tests are problematic and how independent tests support isolated execution; done means both failure cascading and it.only()/mocha -g usage are covered.
Written by the indexing model from the issue text.
Description
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()ormocha -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.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 34
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from loopbackio/loopback-next
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
loopbackio/loopback-next#11726 ·
-
bug
Difficulty 5/5 Over a week Newbie friendliness 35/100
loopbackio/loopback-next#11500 · 1 comment · 1 reaction ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
loopbackio/loopback-next#11412 · 1 comment ·
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 45/100
loopbackio/loopback-next#11396 · 2 comments · 1 reaction ·
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 48/100
loopbackio/loopback-next#11363 · 3 comments ·
All issues in loopbackio/loopback-next
Similar issues
-
comp/desktop P3 type/bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
NousResearch/hermes-agent#118866 ·
-
Browser Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
getsentry/sentry-javascript#24577 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
agilepathway/label-checker#640 ·
-
Plugin stuck at "loading" on DSH 0.1.6-alpha.2 — turnTail list slot registration missing options.id Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
chrisparsons83/flexspotff#153 ·