cleanup: remove AsyncLocalStorage check from tests (#6147)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Phillip Barta · committed by GitHub · parent 9f8589e · Browse files · 7 files·+28 added−92 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Wes Todd <wes@wesleytodd.com>
Diff stats
7 files+28 added−92 removed
- tests:+26 added−92 removed
- other:+2 added−0 removed
Provenance
- Commit
4e92ac9- Tree
3e5f703- Author
Phillip Barta <barta.phillip@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
9f8589e
7 files changed+28 added−92 removed
modified:test/express.json.js+4 added-15 removed
1 'use strict'2 3 var assert = require('assert')4-var asyncHooks = tryRequire('async_hooks')4+var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage5+6 var express = require('..')7 var request = require('supertest')8 8-var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'9- ? describe10- : describe.skip11-9 describe('express.json()', function () {10 it('should parse JSON', function (done) {11 request(createApp())12 .post('/')485 unmodified lines498 test.expect(415, '[charset.unsupported] unsupported charset "X-BOGUS"', done)499 })500 })501 505- describeAsyncHooks('async local storage', function () {502+ describe('async local storage', function () {503 before(function () {504 var app = express()505 var store = { foo: 'bar' }506 507 app.use(function (req, res, next) {511- req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()508+ req.asyncLocalStorage = new AsyncLocalStorage()509 req.asyncLocalStorage.run(store, next)510 })511 512 app.use(express.json())238 unmodified lines751 assert.ok(res.text.indexOf(str) !== -1,752 'expected \'' + res.text + '\' to contain \'' + str + '\'')753 }754 }758-759-function tryRequire (name) {760- try {761- return require(name)762- } catch (e) {763- return {}764- }765-}modified:test/express.raw.js+4 added-15 removed
1 'use strict'2 3 var assert = require('assert')4-var asyncHooks = tryRequire('async_hooks')4+var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage5+6 var express = require('..')7 var request = require('supertest')8 8-var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'9- ? describe10- : describe.skip11-9 describe('express.raw()', function () {10 before(function () {11 this.app = createApp()12 })310 unmodified lines323 test.expect(200, { buf: '0102' }, done)324 })325 })326 330- describeAsyncHooks('async local storage', function () {327+ describe('async local storage', function () {328 before(function () {329 var app = express()330 var store = { foo: 'bar' }331 332 app.use(function (req, res, next) {336- req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()333+ req.asyncLocalStorage = new AsyncLocalStorage()334 req.asyncLocalStorage.run(store, next)335 })336 337 app.use(express.raw())171 unmodified lines509 })510 511 return app512 }516-517-function tryRequire (name) {518- try {519- return require(name)520- } catch (e) {521- return {}522- }523-}modified:test/express.text.js+4 added-15 removed
1 'use strict'2 3 var assert = require('assert')4-var asyncHooks = tryRequire('async_hooks')4+var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage5+6 var express = require('..')7 var request = require('supertest')8 8-var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'9- ? describe10- : describe.skip11-9 describe('express.text()', function () {10 before(function () {11 this.app = createApp()12 })343 unmodified lines356 test.expect(415, '[charset.unsupported] unsupported charset "X-BOGUS"', done)357 })358 })359 363- describeAsyncHooks('async local storage', function () {360+ describe('async local storage', function () {361 before(function () {362 var app = express()363 var store = { foo: 'bar' }364 365 app.use(function (req, res, next) {369- req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()366+ req.asyncLocalStorage = new AsyncLocalStorage()367 req.asyncLocalStorage.run(store, next)368 })369 370 app.use(express.text())192 unmodified lines563 })564 565 return app566 }570-571-function tryRequire (name) {572- try {573- return require(name)574- } catch (e) {575- return {}576- }577-}modified:test/express.urlencoded.js+4 added-15 removed
1 'use strict'2 3 var assert = require('assert')4-var asyncHooks = tryRequire('async_hooks')4+var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage5+6 var express = require('..')7 var request = require('supertest')8 8-var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'9- ? describe10- : describe.skip11-9 describe('express.urlencoded()', function () {10 before(function () {11 this.app = createApp()12 })588 unmodified lines601 test.expect(415, '[charset.unsupported] unsupported charset "X-BOGUS"', done)602 })603 })604 608- describeAsyncHooks('async local storage', function () {605+ describe('async local storage', function () {606 before(function () {607 var app = express()608 var store = { foo: 'bar' }609 610 app.use(function (req, res, next) {614- req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()611+ req.asyncLocalStorage = new AsyncLocalStorage()612 req.asyncLocalStorage.run(store, next)613 })614 615 app.use(express.urlencoded())208 unmodified lines824 return function (res) {825 assert.strictEqual(Object.keys(JSON.parse(res.text)).length, count)826 }827 }831-832-function tryRequire (name) {833- try {834- return require(name)835- } catch (e) {836- return {}837- }838-}modified:test/res.download.js+5 added-16 removed
1 'use strict'2 3 var after = require('after');4 var assert = require('assert')5-var asyncHooks = tryRequire('async_hooks')5+var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage6+7 var express = require('..');8 var path = require('path')9 var request = require('supertest');10 var utils = require('./support/utils')11 12 var FIXTURES_PATH = path.join(__dirname, 'fixtures')13 13-var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'14- ? describe15- : describe.skip16-14 describe('res', function(){15 describe('.download(path)', function(){16 it('should transfer as an attachment', function(done){17 var app = express();68 unmodified lines86 .expect('Content-Disposition', 'attachment; filename="user.html"')87 .expect(200, cb);88 })89 93- describeAsyncHooks('async local storage', function () {90+ describe('async local storage', function () {91 it('should presist store', function (done) {92 var app = express()93 var cb = after(2, done)94 var store = { foo: 'bar' }95 96 app.use(function (req, res, next) {100- req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()97+ req.asyncLocalStorage = new AsyncLocalStorage()98 req.asyncLocalStorage.run(store, next)99 })100 101 app.use(function (req, res) {18 unmodified lines120 var app = express()121 var store = { foo: 'bar' }122 123 app.use(function (req, res, next) {127- req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()124+ req.asyncLocalStorage = new AsyncLocalStorage()125 req.asyncLocalStorage.run(store, next)126 })127 128 app.use(function (req, res) {354 unmodified lines483 .expect(200, 'failed', done)484 })485 })486 })490-491-function tryRequire (name) {492- try {493- return require(name)494- } catch (e) {495- return {}496- }497-}modified:test/res.sendFile.js+5 added-16 removed
1 'use strict'2 3 var after = require('after');4 var assert = require('assert')5-var asyncHooks = tryRequire('async_hooks')5+var AsyncLocalStorage = require('async_hooks').AsyncLocalStorage6+7 var express = require('../')8 , request = require('supertest')9 var onFinished = require('on-finished');10 var path = require('path');11 var fixtures = path.join(__dirname, 'fixtures');12 var utils = require('./support/utils');13 13-var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'14- ? describe15- : describe.skip16-14 describe('res', function(){15 describe('.sendFile(path)', function () {16 it('should error missing path', function (done) {17 var app = createApp();244 unmodified lines262 .get('/')263 .expect(200, 'got 404 error', done)264 })265 269- describeAsyncHooks('async local storage', function () {266+ describe('async local storage', function () {267 it('should presist store', function (done) {268 var app = express()269 var cb = after(2, done)270 var store = { foo: 'bar' }271 272 app.use(function (req, res, next) {276- req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()273+ req.asyncLocalStorage = new AsyncLocalStorage()274 req.asyncLocalStorage.run(store, next)275 })276 277 app.use(function (req, res) {17 unmodified lines295 var app = express()296 var store = { foo: 'bar' }297 298 app.use(function (req, res, next) {302- req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()299+ req.asyncLocalStorage = new AsyncLocalStorage()300 req.asyncLocalStorage.run(store, next)301 })302 303 app.use(function (req, res) {592 unmodified lines896 });897 898 return app;899 }903-904-function tryRequire (name) {905- try {906- return require(name)907- } catch (e) {908- return {}909- }910-}modified:History.md+2 added
1 unreleased2 ========================3 4 * Remove `Object.setPrototypeOf` polyfill5+* cleanup: remove AsyncLocalStorage check from tests6 * cleanup: remove unnecessary require for global Buffer7 8+9 5.0.1 / 2024-10-0810 ==========11 12 * Update `cookie` semver lock to address [CVE-2024-47764](https://nvd.nist.gov/vuln/detail/CVE-2024-47764)3830 unmodified lines