Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make sure that Debug integration is always setup as the last one #2285

Merged
merged 1 commit into from Nov 8, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/core/src/integration.ts
Expand Up @@ -40,7 +40,14 @@ export function getIntegrationsToSetup(options: Options): Integration[] {
integrations = userIntegrations(defaultIntegrations);
integrations = Array.isArray(integrations) ? integrations : [integrations];
} else {
return [...defaultIntegrations];
integrations = [...defaultIntegrations];
}

// Make sure that if present, `Debug` integration will always run last
const integrationsNames = integrations.map(i => i.name);
const alwaysLastToRun = 'Debug';
if (integrationsNames.indexOf(alwaysLastToRun) !== -1) {
integrations.push(...integrations.splice(integrationsNames.indexOf(alwaysLastToRun), 1));
}

return integrations;
Expand Down
23 changes: 23 additions & 0 deletions packages/core/test/lib/integration.test.ts
Expand Up @@ -122,4 +122,27 @@ describe('getIntegrationsToSetup', () => {
expect((integrations[0] as any).order).toEqual('firstUser');
expect((integrations[1] as any).order).toEqual('secondUser');
});

it('always moves Debug integration to the end of the list', () => {
let integrations = getIntegrationsToSetup({
defaultIntegrations: [new MockIntegration('Debug'), new MockIntegration('foo')],
integrations: [new MockIntegration('bar')],
});

expect(integrations.map(i => i.name)).toEqual(['foo', 'bar', 'Debug']);

integrations = getIntegrationsToSetup({
defaultIntegrations: [new MockIntegration('foo')],
integrations: [new MockIntegration('Debug'), new MockIntegration('bar')],
});

expect(integrations.map(i => i.name)).toEqual(['foo', 'bar', 'Debug']);

integrations = getIntegrationsToSetup({
defaultIntegrations: [new MockIntegration('Debug')],
integrations: [new MockIntegration('foo')],
});

expect(integrations.map(i => i.name)).toEqual(['foo', 'Debug']);
});
});