From 732a05ea46b5891d99bc3b0cd97ebd26f6a168dc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:50:21 +0000 Subject: [PATCH 1/2] chore(deps): update testing tools --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c88d737..3e14962 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ "@types/chai-as-promised": "^7.1.8", "@types/mocha": "^10.0.6", "@types/node": ">= 20.11.6", - "c8": "^8.0.1", - "chai": "^4.4.1", + "c8": "^9.1.0", + "chai": "^5.0.3", "chai-as-promised": "^7.1.1", "eslint-formatter-gha": "^1.4.3", "eslint-plugin-mocha": "^10.2.0", From b82eca65f1dcec32c5155357bee5545b3cba1d9a Mon Sep 17 00:00:00 2001 From: Myrotvorets Date: Thu, 25 Jan 2024 18:56:21 +0200 Subject: [PATCH 2/2] Make things work again --- .mocharc.js | 3 +- mocha.setup.js | 6 -- package-lock.json | 141 ++++++++++++------------------ package.json | 2 - test/bufferstream.test.ts | 5 +- test/streamtobuffer.test.ts | 10 ++- test/types.ts | 5 ++ test/writablebufferstream.test.ts | 3 +- 8 files changed, 73 insertions(+), 102 deletions(-) delete mode 100644 mocha.setup.js create mode 100644 test/types.ts diff --git a/.mocharc.js b/.mocharc.js index cd086a4..c83aea7 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -1,7 +1,8 @@ module.exports = { recursive: true, extension: ['.test.ts'], - require: 'mocha.setup.js', + 'node-option': ['loader=ts-node/esm', 'no-warnings'], + require: ['chai/register-expect.js', 'ts-node/register'], reporter: 'mocha-multi', 'reporter-option': [ 'spec=-', diff --git a/mocha.setup.js b/mocha.setup.js deleted file mode 100644 index 275d24d..0000000 --- a/mocha.setup.js +++ /dev/null @@ -1,6 +0,0 @@ -require('ts-node/register'); - -const { use } = require('chai'); -const chaiAsPromised = require('chai-as-promised'); - -use(chaiAsPromised); diff --git a/package-lock.json b/package-lock.json index a2d6e85..cbaae32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,12 +11,10 @@ "devDependencies": { "@myrotvorets/eslint-config-myrotvorets-ts": "^2.24.0", "@types/chai": "^4.3.11", - "@types/chai-as-promised": "^7.1.8", "@types/mocha": "^10.0.6", "@types/node": ">= 20.11.6", - "c8": "^8.0.1", - "chai": "^4.4.1", - "chai-as-promised": "^7.1.1", + "c8": "^9.1.0", + "chai": "^5.0.3", "eslint-formatter-gha": "^1.4.3", "eslint-plugin-mocha": "^10.2.0", "mocha": "^10.2.0", @@ -359,15 +357,6 @@ "integrity": "sha512-qQR1dr2rGIHYlJulmr8Ioq3De0Le9E4MJ5AiaeAETJJpndT1uUNHsGFK3L/UIu+rbkQSdj8J/w2bCsBZc/Y5fQ==", "dev": true }, - "node_modules/@types/chai-as-promised": { - "version": "7.1.8", - "resolved": "https://registry.npmjs.org/@types/chai-as-promised/-/chai-as-promised-7.1.8.tgz", - "integrity": "sha512-ThlRVIJhr69FLlh6IctTXFkmhtP3NpMZ2QGq69StYLyKZFp/HOp1VdKZj7RvfNWYYcJ1xlbLGLLWj1UvP5u/Gw==", - "dev": true, - "dependencies": { - "@types/chai": "*" - } - }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", @@ -849,12 +838,12 @@ } }, "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", "dev": true, "engines": { - "node": "*" + "node": ">=12" } }, "node_modules/available-typed-arrays": { @@ -913,19 +902,18 @@ "dev": true }, "node_modules/c8": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/c8/-/c8-8.0.1.tgz", - "integrity": "sha512-EINpopxZNH1mETuI0DzRA4MZpAUH+IFiRhnmFD3vFr3vdrgxqi3VfE3KL0AIL+zDq8rC9bZqwM/VDmmoe04y7w==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/c8/-/c8-9.1.0.tgz", + "integrity": "sha512-mBWcT5iqNir1zIkzSPyI3NCR9EZCVI3WUD+AVO17MVWTSFNyUueXE82qTeampNtTr+ilN/5Ua3j24LgbCKjDVg==", "dev": true, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", "@istanbuljs/schema": "^0.1.3", "find-up": "^5.0.0", - "foreground-child": "^2.0.0", + "foreground-child": "^3.1.1", "istanbul-lib-coverage": "^3.2.0", "istanbul-lib-report": "^3.0.1", "istanbul-reports": "^3.1.6", - "rimraf": "^3.0.2", "test-exclude": "^6.0.0", "v8-to-istanbul": "^9.0.0", "yargs": "^17.7.2", @@ -935,7 +923,7 @@ "c8": "bin/c8.js" }, "engines": { - "node": ">=12" + "node": ">=14.14.0" } }, "node_modules/call-bind": { @@ -976,33 +964,28 @@ } }, "node_modules/chai": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", - "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.0.3.tgz", + "integrity": "sha512-wKGCtYv2kVY5WEjKqQ3fSIZWtTFveZCtzinhTZbx3/trVkxefiwovhpU9kRVCwxvKKCEjTWXPdM1/T7zPoDgow==", "dev": true, "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.3", - "deep-eql": "^4.1.3", - "get-func-name": "^2.0.2", - "loupe": "^2.3.6", - "pathval": "^1.1.1", - "type-detect": "^4.0.8" + "assertion-error": "^2.0.1", + "check-error": "^2.0.0", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" }, "engines": { - "node": ">=4" + "node": ">=12" } }, - "node_modules/chai-as-promised": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", - "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", + "node_modules/chai/node_modules/check-error": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.0.0.tgz", + "integrity": "sha512-tjLAOBHKVxtPoHe/SA7kNOMvhCRdCJ3vETdeY0RuAc9popf+hyaSV6ZEg9hr4cpWF7jmo/JSWEnLDrnijS9Tog==", "dev": true, - "dependencies": { - "check-error": "^1.0.2" - }, - "peerDependencies": { - "chai": ">= 2.1.2 < 5" + "engines": { + "node": ">= 16" } }, "node_modules/chalk": { @@ -1021,18 +1004,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/check-error": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", - "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", - "dev": true, - "dependencies": { - "get-func-name": "^2.0.2" - }, - "engines": { - "node": "*" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -1166,13 +1137,10 @@ } }, "node_modules/deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.1.tgz", + "integrity": "sha512-nwQCf6ne2gez3o1MxWifqkciwt0zhl0LO1/UwVu4uMBuPmflWM4oQ70XMqHqnBJA+nhzncaqL9HVL6KkHJ28lw==", "dev": true, - "dependencies": { - "type-detect": "^4.0.0" - }, "engines": { "node": ">=6" } @@ -2021,16 +1989,19 @@ } }, "node_modules/foreground-child": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", - "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", "dev": true, "dependencies": { "cross-spawn": "^7.0.0", - "signal-exit": "^3.0.2" + "signal-exit": "^4.0.1" }, "engines": { - "node": ">=8.0.0" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/fs.realpath": { @@ -2909,9 +2880,9 @@ } }, "node_modules/loupe": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", - "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.0.tgz", + "integrity": "sha512-qKl+FrLXUhFuHUoDJG7f8P8gEMHq9NFS0c6ghXG1J0rldmZFQZoNVv/vyirE9qwCIhWZDsvEFd1sbFu3GvRQFg==", "dev": true, "dependencies": { "get-func-name": "^2.0.1" @@ -3402,12 +3373,12 @@ } }, "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", "dev": true, "engines": { - "node": "*" + "node": ">= 14.16" } }, "node_modules/picomatch": { @@ -3598,6 +3569,7 @@ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, + "peer": true, "dependencies": { "glob": "^7.1.3" }, @@ -3781,10 +3753,16 @@ } }, "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } }, "node_modules/slash": { "version": "3.0.0", @@ -4103,15 +4081,6 @@ "node": ">= 0.8.0" } }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", diff --git a/package.json b/package.json index 3e14962..d105a92 100644 --- a/package.json +++ b/package.json @@ -27,12 +27,10 @@ "devDependencies": { "@myrotvorets/eslint-config-myrotvorets-ts": "^2.24.0", "@types/chai": "^4.3.11", - "@types/chai-as-promised": "^7.1.8", "@types/mocha": "^10.0.6", "@types/node": ">= 20.11.6", "c8": "^9.1.0", "chai": "^5.0.3", - "chai-as-promised": "^7.1.1", "eslint-formatter-gha": "^1.4.3", "eslint-plugin-mocha": "^10.2.0", "mocha": "^10.2.0", diff --git a/test/bufferstream.test.ts b/test/bufferstream.test.ts index 61894f5..8212a8a 100644 --- a/test/bufferstream.test.ts +++ b/test/bufferstream.test.ts @@ -1,11 +1,12 @@ -import { expect } from 'chai'; import { BufferStream, streamToBuffer } from '../lib'; +import './types'; + describe('BufferStream', function (): void { it('should convert a Buffer into a ReadableStream', function () { const buf = Buffer.from('123'); const stream = new BufferStream(buf); - return expect(streamToBuffer(stream)).to.become(buf); + return streamToBuffer(stream).then((result) => expect(result).to.deep.equal(buf)); }); }); diff --git a/test/streamtobuffer.test.ts b/test/streamtobuffer.test.ts index 75590bf..9728de5 100644 --- a/test/streamtobuffer.test.ts +++ b/test/streamtobuffer.test.ts @@ -1,8 +1,9 @@ import { createReadStream, promises } from 'node:fs'; import { Readable } from 'node:stream'; -import { expect } from 'chai'; import { streamToBuffer } from '../lib'; +import './types'; + const error = new Error('путин - хуйло'); class FailingStream extends Readable { @@ -14,12 +15,15 @@ class FailingStream extends Readable { describe('streamToBuffer', function () { it('should reject on stream faulres', function () { const stream = new FailingStream(); - return expect(streamToBuffer(stream)).to.be.eventually.rejectedWith(error); + return streamToBuffer(stream).then( + () => expect.fail('should not resolve'), + (err) => expect(err).to.equal(error), + ); }); it('should produce the same result as readFile', async function () { const expected = await promises.readFile(__filename); const stream = createReadStream(__filename); - return expect(streamToBuffer(stream)).to.become(expected); + return streamToBuffer(stream).then((result) => expect(result).to.deep.equal(expected)); }); }); diff --git a/test/types.ts b/test/types.ts new file mode 100644 index 0000000..91bd7c2 --- /dev/null +++ b/test/types.ts @@ -0,0 +1,5 @@ +export {}; + +declare global { + const expect: typeof chai.expect; +} diff --git a/test/writablebufferstream.test.ts b/test/writablebufferstream.test.ts index 80806e9..89be604 100644 --- a/test/writablebufferstream.test.ts +++ b/test/writablebufferstream.test.ts @@ -1,5 +1,4 @@ -import { expect } from 'chai'; -import { WritableBufferStream } from '../lib'; +import { WritableBufferStream } from '../lib/index'; describe('WritableBufferStream', function (): void { it('should have the initial buffer as null', function () {