Skip to content

Commit

Permalink
Tests: bump web-streams-polyfill to v4 to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
larabr committed Jun 25, 2024
1 parent ec34e8a commit 8327273
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"ts-node": "^10.9.2",
"tsx": "^4.7.0",
"typescript": "^5.5.2",
"web-streams-polyfill": "^3.3.2"
"web-streams-polyfill": "^4.0.0"
},
"peerDependencies": {
"typescript": ">=4.2"
Expand Down
6 changes: 3 additions & 3 deletions test/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ describe('Node integration tests', () => {
it('polyfilled web stream cannot be converted into node native stream', async () => {
const { ReadableStream: PolyfilledReadableStream } = await import ('web-streams-polyfill');

// this test is just to keep track that this behaviour is expected
// this test is just to keep track that this behaviour is expected: it does not cause a TS error, but a runtime one
const input = 'chunk';
const stream = new PolyfilledReadableStream({
const stream: NodeWebReadableStream<string> = new PolyfilledReadableStream<string>({
start(controller) {
controller.enqueue(input);
controller.close();
}
});
const streamedData = toStream(stream);
// @ts-expect-error `fromWeb` does not accept the polyfilled stream
// `fromWeb` does not accept the polyfilled stream
expect(() => NodeNativeReadableStream.fromWeb(streamedData)).to.throw(/must be an instance of ReadableStream/);
});
});
4 changes: 2 additions & 2 deletions test/typescript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const newEmptyWebStream = <T extends Data>(): WebStream<T> => new WebReadableStr
const expectedWebStreamButActualNodeStream: WebStream<string> = toStream(nodeWebStream);
assert(expectedWebStreamButActualNodeStream instanceof NodeWebReadableStream);
const newStringStream: Stream<string> = toStream('chunk');
assert(newStringStream instanceof WebReadableStream); // ReadableStream is polyfilled
assert(newStringStream instanceof NodeWebReadableStream);
// @ts-expect-error detect type parameter mismatch
const anotherStringStream: Stream<Uint8Array> = toStream('chunk');
assert(anotherStringStream instanceof WebReadableStream); // ReadableStream is polyfilled
assert(anotherStringStream instanceof NodeWebReadableStream);

assert(isArrayStream(new ArrayStream())) ; // ensure Array is actually extended in e.g. es5

Expand Down

0 comments on commit 8327273

Please sign in to comment.