Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions change/beachball-e606449d-61ec-4934-8a24-91aa58cae28b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Tests: update verdaccio to v6",
"packageName": "beachball",
"email": "elcraig@microsoft.com",
"dependentChangeType": "none"
}
22 changes: 5 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,50 +46,38 @@
"devDependencies": {
"@eslint/compat": "^2.0.0",
"@eslint/js": "^9.0.0",
"@jest/globals": "^29.0.0",
"@jest/globals": "^30.0.0",
"@types/node": "^22.0.0",
"@types/yargs-parser": "^21.0.0",
"@typescript-eslint/utils": "^8.52.0",
"depcheck": "^1.4.7",
"eslint": "^9.0.0",
"eslint-config-prettier": "^10.1.8",
"husky": "^9.0.0",
"jest": "^29.0.0",
"jest": "^30.0.0",
"lage": "^2.15.0",
"lint-staged": "^16.0.0",
"prettier": "~3.8.3",
"syncpack": "^9.0.0",
"ts-jest": "29.2.6",
"ts-jest": "^29.4.0",
"typescript": "~6.0.0",
"typescript-eslint": "^8.52.0"
},
"resolutions": {
"@types/node": "^22.0.0",
"lodash": "^4.18.1",
"body-parser/qs@6.11.0": "^6.14.2",
"express/qs@6.11.0": "^6.14.2",
"@cypress/request/qs@6.10.4": "^6.14.2",
"syncpack/minimatch@6.2.0": "^6.2.3",
"syncpack/semver@7.5.0": "^7.7.4",
"verdaccio/handlebars@4.7.8": "^4.7.9",
"verdaccio/js-yaml@4.1.0": "^4.1.0",
"verdaccio/validator@13.11.0": "^13.15.22",
"@verdaccio/config/js-yaml@4.1.0": "^4.1.0",
"@verdaccio/config/minimatch@7.4.6": "^7.4.9",
"@verdaccio/core/ajv@8.12.0": "^8.18.0",
"@verdaccio/url/validator@13.11.0": "^13.15.22",
"@verdaccio/utils/minimatch@7.4.6": "^7.4.9"
"@verdaccio/core/ajv@8.17.1": "^8.18.0",
"@verdaccio/core/ajv@8.18.0": "^8.18.0"
},
"rationale": {
"devDependencies": {
"ts-jest@29.2.6": "29.3.0 introduces type-fest v4 which requires node 16+"
},
"resolutions": {
"lodash": "Unpin due to security issue",
"*/qs": "Unpin due to security issue",
"*/semver": "Unpin due to security issues",
"*/verdaccio/*": "Unpin due to security issues",
"*/@verdaccio/*/*": "Unpin due to security issues",
"*/minimatch": "Unpin minimatch due to security issues"
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/beachball/.depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ ignores:
- 'eslint-*'
- '@types/node'
- '@jest/globals'
# needed for type references from verdaccio (not listed in deps)
- '@verdaccio/types'
# needed for type references from @verdaccio/types
- '@types/jsonwebtoken'
14 changes: 5 additions & 9 deletions packages/beachball/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,19 @@
},
"devDependencies": {
"@microsoft/beachball-scripts": "1.0.0",
"@types/jsonwebtoken": "^9.0.10",
"@types/minimatch": "^3.0.0",
"@types/prompts": "^2.4.2",
"@types/semver": "^7.3.13",
"@types/tmp": "^0.2.3",
"@types/yargs-parser": "^21.0.0",
"@verdaccio/types": "^13.0.0",
"get-port": "^5.0.0",
"normalized-tmpdir": "1.0.1",
"strip-ansi": "^6.0.1",
"tmp": "^0.2.1",
"verdaccio": "5.29.2",
"verdaccio-auth-memory": "10.2.2",
"verdaccio-memory": "10.3.2"
},
"rationale": {
"devDependencies": {
"verdaccio-auth-memory@10.2.2": "node 18 required by newer version",
"verdaccio-memory@10.3.2": "node 18 required by newer version"
}
"verdaccio": "^6.5.2",
"verdaccio-auth-memory": "^13.0.0",
"verdaccio-memory": "^10.4.3"
}
}
5 changes: 3 additions & 2 deletions packages/beachball/src/__fixtures__/mockNpm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
_mockNpmPublish,
_mockNpmShow,
type MockNpmResult,
type MockNpmCommand,
} from './mockNpm';
import * as readJsonModule from '../object/readJson';

Expand Down Expand Up @@ -505,15 +506,15 @@ describe('mockNpm', () => {
const fakePublishResult = 'hi';

it('respects mocked command override', async () => {
const mockPublish = jest.fn(() => Promise.resolve(fakePublishResult as unknown as MockNpmResult));
const mockPublish = jest.fn<MockNpmCommand>(() => Promise.resolve(fakePublishResult as unknown as MockNpmResult));
npmMock.setCommandOverride('publish', mockPublish);
const result = await npm(['publish', 'foo'], { cwd: '' });
expect(result).toEqual(fakePublishResult);
expect(mockPublish).toHaveBeenCalledWith(expect.any(Object), ['foo'], { cwd: '' });
});

it("respects extra mocked command that's not normally supported", async () => {
const mockFoo = jest.fn(() => Promise.resolve('hi' as unknown as MockNpmResult));
const mockFoo = jest.fn<MockNpmCommand>(() => Promise.resolve('hi' as unknown as MockNpmResult));
npmMock.setCommandOverride('foo', mockFoo);
const result = await npm(['foo'], { cwd: '' });
expect(result).toEqual('hi');
Expand Down
2 changes: 1 addition & 1 deletion packages/beachball/src/__fixtures__/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class Registry {
configBuilder.addLogger({
type: 'file',
level: 'trace',
format: 'file',
format: 'pretty',
path: path.join(process.cwd(), `verdaccio-${Date.now()}.log`),
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`writeChangelog generates basic changelog: changelog md 1`] = `
"# Change Log - foo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`publish command logs expected output for a standard publish flow 1`] = `
"[log]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ const testPackage = { name: testName, version: testVersion };
// The rest mock npm calls for efficiency (but could potentially be updated to use real npm if
// a bug is found that would have been caught that way).
//
// TODO: re-enable when jest and verdaccio are updated
// eslint-disable-next-line no-restricted-properties
describe.skip('packagePublish', () => {
describe('packagePublish', () => {
let npmSpy: jest.SpiedFunction<typeof npm>;
let npmVersion: string;
let tempRoot: string;
let tempPackageJsonPath: string;
/**
Expand Down Expand Up @@ -91,8 +88,6 @@ describe.skip('packagePublish', () => {
tempRoot = tmpdir();
tempPackageJsonPath = path.join(tempRoot, 'package.json');
writeJson(tempPackageJsonPath, testPackage);

npmVersion = (await npmModule.npm(['--version'], { cwd: tempRoot })).stdout.trim() || '';
});

beforeEach(async () => {
Expand Down Expand Up @@ -188,12 +183,6 @@ describe.skip('packagePublish', () => {
});

it('handles auth error and does not retry', async () => {
// TODO: remove condition once node version is upgraded (this test doesn't work with npm 6 because
// that version seems to allow truly anonymous publishing with verdaccio)
if (npmVersion.startsWith('6.')) {
console.warn('Skipping auth error test on npm 6');
return;
}
await registry.logout();

const testPackageInfo = getTestPackageInfo();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`publishToRegistry includes new packages not modified 1`] = `
"[log] Validating new package versions...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('publishToRegistry', () => {
const fooPath = expect.stringMatching(/packages[\\/]foo$/);
// BUG: this should use the old version 1.0.0, not the new one
// https://github.com/microsoft/beachball/issues/1116
expect(prebump).toHaveBeenCalledWith(fooPath, 'foo', '1.0.1', expect.anything());
expect(prebump as typeof postbump).toHaveBeenCalledWith(fooPath, 'foo', '1.0.1', expect.anything());
// this is correct
expect(postbump).toHaveBeenCalledWith(fooPath, 'foo', '1.0.1', expect.anything());
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`renderChangelog handles no previous content 1`] = `
"# Change Log - foo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`changelog renderers - renderPackageChangelog has correct grouped output 1`] = `
"## 1.2.3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`bumpAndPush retries on fetch failure then succeeds 2`] = `
"[log] --------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions packages/beachball/src/__tests__/publish/tagPackages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.mock('workspace-tools', () => ({
const gitFailFast = _gitFailFast as jest.MockedFunction<typeof _gitFailFast>;

const createTagParameters = (tag: string) => {
return [['tag', '-a', '-f', tag, '-m', tag], { cwd: '' }];
return [['tag', '-a', '-f', tag, '-m', tag], { cwd: '' }] as [string[], { cwd: string }];
};

type TagBumpInfo = Parameters<typeof tagPackages>[0];
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('tagPackages', () => {

it('creates overall git tag for non-"latest" dist tag', () => {
tagPackages(emptyBumpInfo, { path: '', gitTags: true, tag: 'abc' });
expect(gitFailFast).toBeCalledTimes(1);
expect(gitFailFast).toHaveBeenCalledTimes(1);
expect(gitFailFast).toHaveBeenCalledWith(...createTagParameters('abc'));
});
});
2 changes: 1 addition & 1 deletion scripts/config/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getProjectOptions(projectOverrides) {
'^.+\\.tsx?$': [
'ts-jest',
// in ts-jest, this means skip type checking (we already type check in the build step)
{ isolatedModules: true },
{ tsconfig: { isolatedModules: true } },
],
},
testEnvironment: 'node',
Expand Down
3 changes: 0 additions & 3 deletions scripts/config/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
// Use CJS output for now
"module": "node20",
"moduleResolution": "node16",
// For some reason, jest is failing with this error which isn't even an option specified...
// TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0
"ignoreDeprecations": "6.0",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
Expand Down
Loading
Loading