test: remove Buffer.concat overwrite (#11876)

This commit is contained in:
Nikolay Vitkov 2024-02-08 12:00:37 +01:00 committed by GitHub
parent 3b43b1fa07
commit 86c3988e26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 23 deletions

View File

@ -209,7 +209,7 @@ export async function getReadableAsBuffer(
readable: ReadableStream<Uint8Array>,
path?: string
): Promise<Buffer | null> {
const buffers = [];
const buffers: Uint8Array[] = [];
const reader = readable.getReader();
if (path) {
const fs = await importFSPromises();

View File

@ -1521,18 +1521,6 @@
"parameters": ["cdp", "firefox"],
"expectations": ["FAIL"]
},
{
"testIdPattern": "[browsercontext.spec] BrowserContext window.open should use parent tab context",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[browsercontext.spec] BrowserContext window.open should use parent tab context",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["firefox", "webDriverBiDi"],
"expectations": ["PASS"]
},
{
"testIdPattern": "[CDPSession.spec] Target.createCDPSession should be able to detach session",
"platforms": ["darwin", "linux", "win32"],

View File

@ -8,6 +8,8 @@ import fs from 'fs';
import path from 'path';
import expect from 'expect';
import * as utils from 'puppeteer-core/internal/common/util.js';
import sinon from 'sinon';
import {launch} from './mocha-utils.js';
@ -113,16 +115,26 @@ describe('Tracing', function () {
await page.tracing.start({screenshots: true});
await page.goto(server.PREFIX + '/grid.html');
const oldBufferConcat = Buffer.concat;
try {
Buffer.concat = () => {
throw new Error('error');
};
const trace = await page.tracing.stop();
expect(trace).toEqual(undefined);
} finally {
Buffer.concat = oldBufferConcat;
}
const oldGetReadableAsBuffer = utils.getReadableAsBuffer;
sinon.stub(utils, 'getReadableAsBuffer').callsFake(() => {
return oldGetReadableAsBuffer({
getReader() {
return {
done: false,
read() {
if (!this.done) {
this.done = true;
return {done: false, value: 42};
}
return {done: true};
},
};
},
} as unknown as ReadableStream);
});
const trace = await page.tracing.stop();
expect(trace).toEqual(undefined);
});
it('should support a buffer without a path', async () => {