Skip to content
Open
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
24 changes: 24 additions & 0 deletions packages/web-worker/types/notifier.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { WorkerConfig } from './notifier';

describe('WorkerConfig type', () => {
it('should allow apiKey and custom fields', () => {
// This should type-check without error
Comment on lines +1 to +5
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file uses semicolons, which will violate the repo’s Standard/standard-with-typescript lint rules (existing *.test.ts files in this repo omit semicolons). Please align formatting with the project style (remove semicolons, trailing punctuation) to avoid CI lint failures.

Copilot uses AI. Check for mistakes.
const config: WorkerConfig = {
apiKey: '123',
collectUserIp: true,
generateAnonymousId: false
};
Comment on lines +3 to +10
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name says it "should allow apiKey and custom fields", but the object literal only uses declared WorkerConfig fields (apiKey, collectUserIp, generateAnonymousId). Either add an actual extra property to demonstrate custom fields (if intended/supported), or rename the test to reflect what it’s asserting.

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +10
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name/comment says “custom fields”, but the object literal only uses known properties (apiKey, collectUserIp, generateAnonymousId). Also, WorkerConfig (via Config) doesn’t appear to allow arbitrary extra keys, so this wording is misleading. Please rename the test to reflect what’s actually being exercised, or add a true “extra property allowed” case if that’s intended behavior.

Copilot uses AI. Check for mistakes.
expect(config.apiKey).toBe('123');
expect(config.collectUserIp).toBe(true);
expect(config.generateAnonymousId).toBe(false);
});
Comment on lines +1 to +14
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file’s formatting (semicolons, etc.) doesn’t match the repo’s ESLint config (standard-with-typescript), which enforces a no-semicolons style for *.ts/*.test.ts. Running npm run test:lint will likely fail on this file; please align it with the existing test style in packages/web-worker/test/*.ts.

Copilot uses AI. Check for mistakes.

it('should error if apiKey is missing', () => {
// @ts-expect-error: apiKey is required
const config: WorkerConfig = {
collectUserIp: true,
generateAnonymousId: false
};
expect(config).toBeDefined();
Comment on lines +15 to +22
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test intends to assert type behavior (including @ts-expect-error), but Jest + Babel compilation won’t fail on TypeScript type errors. Also, packages/web-worker is not included in the root tsconfig.json that’s compiled by npm run test:types, so this file likely won’t be type-checked in CI. To make this meaningful, add a type-check step that includes packages/web-worker/types (e.g. a package-level test:types that runs tsc --noEmit over these files, or include this directory in an existing type-test project).

Copilot uses AI. Check for mistakes.
});
});
Comment on lines +3 to +24
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file lives under packages/web-worker/types/, and packages/web-worker/package.json publishes the entire types directory ("files": ["dist", "types"]). That means this *.test.ts will be shipped to consumers. Consider moving this test into packages/web-worker/test/ (or excluding **/*.test.* from the published files list) so the published package only contains actual type entrypoints.

Suggested change
describe('WorkerConfig type', () => {
it('should allow apiKey and custom fields', () => {
// This should type-check without error
const config: WorkerConfig = {
apiKey: '123',
collectUserIp: true,
generateAnonymousId: false
};
expect(config.apiKey).toBe('123');
expect(config.collectUserIp).toBe(true);
expect(config.generateAnonymousId).toBe(false);
});
it('should error if apiKey is missing', () => {
// @ts-expect-error: apiKey is required
const config: WorkerConfig = {
collectUserIp: true,
generateAnonymousId: false
};
expect(config).toBeDefined();
});
});
// This file intentionally performs compile-time validation for the public type.
// It avoids runtime test constructs so it can safely live alongside published
// type entrypoints without depending on a test framework.
const config: WorkerConfig = {
apiKey: '123',
collectUserIp: true,
generateAnonymousId: false
};
const apiKey: string = config.apiKey;
const collectUserIp: boolean = config.collectUserIp;
const generateAnonymousId: boolean = config.generateAnonymousId;
void apiKey;
void collectUserIp;
void generateAnonymousId;
// @ts-expect-error: apiKey is required
const invalidConfig: WorkerConfig = {
collectUserIp: true,
generateAnonymousId: false
};
void invalidConfig;
export {};

Copilot uses AI. Check for mistakes.
2 changes: 1 addition & 1 deletion packages/web-worker/types/notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ declare const Bugsnag: WorkerBugsnagStatic

export default Bugsnag
export * from '@bugsnag/core'
export { WorkerConfig }
export type { WorkerConfig }
Loading