From 50eb7b2ca4ec7fc2c69acf0438a5561294ef91fc Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Sun, 11 Feb 2024 16:30:26 +0100 Subject: [PATCH] chore: flaky test local storage (#4497) * chore: flaky test local storage * fix test --- jest/config.js | 2 +- packages/plugins/local-storage/package.json | 2 +- .../readme-test/test-readme-0.0.2.tgz | Bin 0 -> 352 bytes .../readme-test/test-readme-0.0.3.tgz | Bin 0 -> 352 bytes .../readme-test/test-readme-0.0.4.tgz | Bin 0 -> 352 bytes .../plugins/local-storage/tests/local-fs.test.ts | 6 +++--- packages/store/test/storage.spec.ts | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.2.tgz create mode 100644 packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.3.tgz create mode 100644 packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.4.tgz diff --git a/jest/config.js b/jest/config.js index 12092757c..ba5826292 100644 --- a/jest/config.js +++ b/jest/config.js @@ -4,7 +4,7 @@ module.exports = { '^.+\\.(js|ts)$': 'babel-jest', }, verbose: false, - collectCoverage: true, + collectCoverage: false, coverageReporters: ['text', 'html'], collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!**/partials/**', '!**/fixture/**'], coveragePathIgnorePatterns: ['node_modules', 'fixtures'], diff --git a/packages/plugins/local-storage/package.json b/packages/plugins/local-storage/package.json index e959e2a26..92fb02c83 100644 --- a/packages/plugins/local-storage/package.json +++ b/packages/plugins/local-storage/package.json @@ -58,7 +58,7 @@ }, "scripts": { "clean": "rimraf ./build", - "test": "jest", + "test": "jest --runInBand", "type-check": "tsc --noEmit -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", diff --git a/packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.2.tgz b/packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.2.tgz new file mode 100644 index 0000000000000000000000000000000000000000..cb18086fac7e59f8601cc740fd7caf2add8f81c7 GIT binary patch literal 352 zcmV-m0iXUKiwFP!000001MQQsZo)7ShBNyqP9B&jbrK+w*Q!J3t}Iq?gA1`O+q59W zyZ7wS7PUxKRaAtOKf|5Qr~l4YJ}c^_XymQ!;^^5Mot;^XvFUgW81rhvj$=|;l#t~` zSrp}@tfqO!@{$!fo}YV>Q(F5V9IocgYhEWxX&kqxa4k$3Yv2b?{c! z>PgA@jKW|5a-#y|bU&m{TH{qPZks%|Hm=vGfZl7jies@!ti!^%ZikhsrS`Gw;qi{{ zFa4xfCHsZ{t!P*0p78_!MOB^Pzv%h@4@LSpe1o4H(C3iICr8|Kpp-=HIlNO(4$N}` y$qHM3!#w#UJ~<%q91wWS5%@H(!#$-3+BqQXgHSF1OP52?8T3;+Pl6|^M) literal 0 HcmV?d00001 diff --git a/packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.3.tgz b/packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.3.tgz new file mode 100644 index 0000000000000000000000000000000000000000..cb18086fac7e59f8601cc740fd7caf2add8f81c7 GIT binary patch literal 352 zcmV-m0iXUKiwFP!000001MQQsZo)7ShBNyqP9B&jbrK+w*Q!J3t}Iq?gA1`O+q59W zyZ7wS7PUxKRaAtOKf|5Qr~l4YJ}c^_XymQ!;^^5Mot;^XvFUgW81rhvj$=|;l#t~` zSrp}@tfqO!@{$!fo}YV>Q(F5V9IocgYhEWxX&kqxa4k$3Yv2b?{c! z>PgA@jKW|5a-#y|bU&m{TH{qPZks%|Hm=vGfZl7jies@!ti!^%ZikhsrS`Gw;qi{{ zFa4xfCHsZ{t!P*0p78_!MOB^Pzv%h@4@LSpe1o4H(C3iICr8|Kpp-=HIlNO(4$N}` y$qHM3!#w#UJ~<%q91wWS5%@H(!#$-3+BqQXgHSF1OP52?8T3;+Pl6|^M) literal 0 HcmV?d00001 diff --git a/packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.4.tgz b/packages/plugins/local-storage/tests/__fixtures__/readme-test/test-readme-0.0.4.tgz new file mode 100644 index 0000000000000000000000000000000000000000..cb18086fac7e59f8601cc740fd7caf2add8f81c7 GIT binary patch literal 352 zcmV-m0iXUKiwFP!000001MQQsZo)7ShBNyqP9B&jbrK+w*Q!J3t}Iq?gA1`O+q59W zyZ7wS7PUxKRaAtOKf|5Qr~l4YJ}c^_XymQ!;^^5Mot;^XvFUgW81rhvj$=|;l#t~` zSrp}@tfqO!@{$!fo}YV>Q(F5V9IocgYhEWxX&kqxa4k$3Yv2b?{c! z>PgA@jKW|5a-#y|bU&m{TH{qPZks%|Hm=vGfZl7jies@!ti!^%ZikhsrS`Gw;qi{{ zFa4xfCHsZ{t!P*0p78_!MOB^Pzv%h@4@LSpe1o4H(C3iICr8|Kpp-=HIlNO(4$N}` y$qHM3!#w#UJ~<%q91wWS5%@H(!#$-3+BqQXgHSF1OP52?8T3;+Pl6|^M) literal 0 HcmV?d00001 diff --git a/packages/plugins/local-storage/tests/local-fs.test.ts b/packages/plugins/local-storage/tests/local-fs.test.ts index 308626540..9c0f03f89 100644 --- a/packages/plugins/local-storage/tests/local-fs.test.ts +++ b/packages/plugins/local-storage/tests/local-fs.test.ts @@ -100,7 +100,7 @@ describe('Local FS test', () => { path.join(__dirname, '__fixtures__/readme-test-next'), logger ); - localFs.readTarball('test-readme-0.0.0.tgz', { signal: abort.signal }).then((stream) => { + localFs.readTarball('test-readme-0.0.1.tgz', { signal: abort.signal }).then((stream) => { stream.on('data', (data) => { expect(data.length).toEqual(352); }); @@ -116,7 +116,7 @@ describe('Local FS test', () => { path.join(__dirname, '__fixtures__/readme-test-next'), logger ); - localFs.readTarball('test-readme-0.0.0.tgz', { signal: abort.signal }).then((stream) => { + localFs.readTarball('test-readme-0.0.3.tgz', { signal: abort.signal }).then((stream) => { stream.on('error', (error: any) => { // FIXME: might be different results sometimes, need research // expect(error.code).toEqual('ABORT_ERR'); @@ -148,11 +148,11 @@ describe('Local FS test', () => { logger ); const abort = new AbortController(); - localFs.readTarball('test-readme-0.0.0.tgz', { signal: abort.signal }).then((stream) => { stream.on('data', (data) => { expect(data.length).toEqual(352); }); + stream.on('content-length', (content) => { expect(content).toEqual(352); done(); diff --git a/packages/store/test/storage.spec.ts b/packages/store/test/storage.spec.ts index 27d1a01d3..414946ff8 100644 --- a/packages/store/test/storage.spec.ts +++ b/packages/store/test/storage.spec.ts @@ -875,7 +875,7 @@ describe('storage', () => { storage: generateRandomStorage(), uplinks: { npmjs: { - url: 'https://registry.npmjs.org', + url: 'https://registry.domain.com', timeout: '2s', }, },