diff --git a/lib/internal/webstreams/compression.js b/lib/internal/webstreams/compression.js index 28b6dc8f7a41bf..92933aae4d38bb 100644 --- a/lib/internal/webstreams/compression.js +++ b/lib/internal/webstreams/compression.js @@ -94,7 +94,7 @@ class CompressionStream { [kInspect](depth, options) { if (!isCompressionStream(this)) throw new ERR_INVALID_THIS('CompressionStream'); - customInspect(depth, options, 'CompressionStream', { + return customInspect(depth, options, 'CompressionStream', { readable: this[kTransform].readable, writable: this[kTransform].writable, }); @@ -146,7 +146,7 @@ class DecompressionStream { [kInspect](depth, options) { if (!isDecompressionStream(this)) throw new ERR_INVALID_THIS('DecompressionStream'); - customInspect(depth, options, 'DecompressionStream', { + return customInspect(depth, options, 'DecompressionStream', { readable: this[kTransform].readable, writable: this[kTransform].writable, }); diff --git a/test/parallel/test-compression-decompression-stream.js b/test/parallel/test-compression-decompression-stream.js new file mode 100644 index 00000000000000..1340c5c8bc44de --- /dev/null +++ b/test/parallel/test-compression-decompression-stream.js @@ -0,0 +1,41 @@ +// Flags: --no-warnings --expose-internals +'use strict'; + +require('../common'); + +const assert = require('node:assert'); +const { describe, it } = require('node:test'); +const { + CompressionStream, + DecompressionStream, +} = require('node:stream/web'); + +const { + customInspectSymbol: kInspect, +} = require('internal/util'); + +describe('DecompressionStream kInspect method', () => { + it('should return a predictable inspection string with DecompressionStream', () => { + const decompressionStream = new DecompressionStream('deflate'); + const depth = 1; + const options = {}; + const actual = decompressionStream[kInspect](depth, options); + + assert(actual.includes('DecompressionStream')); + assert(actual.includes('ReadableStream')); + assert(actual.includes('WritableStream')); + }); +}); + +describe('CompressionStream kInspect method', () => { + it('should return a predictable inspection string with CompressionStream', () => { + const compressionStream = new CompressionStream('deflate'); + const depth = 1; + const options = {}; + const actual = compressionStream[kInspect](depth, options); + + assert(actual.includes('CompressionStream')); + assert(actual.includes('ReadableStream')); + assert(actual.includes('WritableStream')); + }); +});