Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tapjs/after

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tapjs/after - npm Package Compare versions

Comparing version 0.0.0-18 to 0.0.0-19

2

dist/cjs/index.js

@@ -57,3 +57,3 @@ "use strict";

let fn;
while ((fn = this.#onTeardown.shift())) {
while ((fn = this.#onTeardown.pop())) {
try {

@@ -60,0 +60,0 @@ const ret = fn.call(this.#t.t);

@@ -54,3 +54,3 @@ /**

let fn;
while ((fn = this.#onTeardown.shift())) {
while ((fn = this.#onTeardown.pop())) {
try {

@@ -57,0 +57,0 @@ const ret = fn.call(this.#t.t);

{
"name": "@tapjs/after",
"version": "0.0.0-18",
"version": "0.0.0-19",
"description": "a built-in tap extension for t.after() and t.teardown()",

@@ -35,5 +35,3 @@ "type": "module",

"keywords": [
"tap",
"spy",
"fake"
"tapjs plugin"
],

@@ -47,3 +45,3 @@ "author": "Isaac Z. Schlueter",

"peerDependencies": {
"@tapjs/core": "0.0.0-18"
"@tapjs/core": "0.0.0-19"
},

@@ -50,0 +48,0 @@ "engines": {

@@ -52,1 +52,53 @@ # `@tapjs/after`

```
## Order
If multiple teardown methods are assigned to a single test, they
will be run in _reverse_ order of how they are assigned. This is
a change from earlier versions of tap, and provides symmetry with
`t.before()`.
In practice, it can make things more straightforward, by keeping
cleanup methods close to their associated setup logic. For
example:
```js
const connection = await connectToDB()
t.ok(connection, 'connected to database')
t.teardown(() => disconnectFromDB(connection))
const user1 = await createUser(connection)
t.ok(user1, 'created user 1')
t.teardown(() => deleteUser(connection, user1))
const user2 = await createUser(connection)
t.ok(user2, 'created user 2')
t.teardown(() => deleteUser(connection, user2))
```
If we delete the connection created in the first step _before_
deleting the user records, then we can't use that connection to
delete the user records.
This can also be accomplished with subtests, and a single
teardown in each section:
```js
t.test('user db tests', async t => {
const connection = await connectToDB()
t.ok(connection, 'connected to database')
t.teardown(() => disconnectFromDB(connection))
t.test('user 1', async t => {
const user1 = await createUser(connection)
t.ok(user1, 'created user 1')
t.teardown(() => deleteUser(connection, user1))
})
t.test('user 2', async t => {
const user2 = await createUser(connection)
t.ok(user2, 'created user 2')
t.teardown(() => deleteUser(connection, user2))
})
})
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc