Skip to content

Commit

Permalink
chore: Increase unit test timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Mar 12, 2024
1 parent 832cd5d commit d9cba55
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 35 deletions.
66 changes: 31 additions & 35 deletions src/core/package-managers/__tests__/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,41 @@ import { exists } from 'fs-extra';

const cwd = path.resolve(__dirname, 'fixtures/npm-project');

describe(
'NPM Package Management Utils',
() => {
beforeAll(async () => {
// NPM needs the modules installed for 'npm ls' to work
await execaCommand('npm i', { cwd });
});
describe('NPM Package Management Utils', () => {
beforeAll(async () => {
// NPM needs the modules installed for 'npm ls' to work
await execaCommand('npm i', { cwd });
});

describe('listDependencies', () => {
it('should list direct dependencies', async () => {
const actual = await npm.listDependencies({ cwd });
expect(actual).toEqual([
{ name: 'flatten', version: '1.0.3' },
{ name: 'mime-types', version: '2.1.35' },
]);
});
describe('listDependencies', () => {
it('should list direct dependencies', async () => {
const actual = await npm.listDependencies({ cwd });
expect(actual).toEqual([
{ name: 'flatten', version: '1.0.3' },
{ name: 'mime-types', version: '2.1.35' },
]);
});

it('should list all dependencies', async () => {
const actual = await npm.listDependencies({ cwd, all: true });
expect(actual).toEqual([
{ name: 'flatten', version: '1.0.3' },
{ name: 'mime-types', version: '2.1.35' },
{ name: 'mime-db', version: '1.52.0' },
]);
});
it('should list all dependencies', async () => {
const actual = await npm.listDependencies({ cwd, all: true });
expect(actual).toEqual([
{ name: 'flatten', version: '1.0.3' },
{ name: 'mime-types', version: '2.1.35' },
{ name: 'mime-db', version: '1.52.0' },
]);
});
});

describe('downloadDependency', () => {
it('should download the dependency as a tarball', async () => {
const downloadDir = path.resolve(cwd, 'dist');
const id = 'mime-db@1.52.0';
const expected = path.resolve(downloadDir, 'mime-db-1.52.0.tgz');
describe('downloadDependency', () => {
it('should download the dependency as a tarball', async () => {
const downloadDir = path.resolve(cwd, 'dist');
const id = 'mime-db@1.52.0';
const expected = path.resolve(downloadDir, 'mime-db-1.52.0.tgz');

const actual = await npm.downloadDependency(id, downloadDir);
const actual = await npm.downloadDependency(id, downloadDir);

expect(actual).toEqual(expected);
expect(await exists(actual)).toBe(true);
});
expect(actual).toEqual(expected);
expect(await exists(actual)).toBe(true);
});
},
{ timeout: 20e3 },
);
});
});
1 change: 1 addition & 0 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default defineWorkspace([
mockReset: true,
restoreMocks: true,
setupFiles: 'vitest.setup.ts',
testTimeout: 20e3,
},
plugins: [testSeed()],
resolve,
Expand Down

0 comments on commit d9cba55

Please sign in to comment.