Skip to content

Commit

Permalink
feat: Expose instantiation parameters to error monitoring for better …
Browse files Browse the repository at this point in the history
…messages
  • Loading branch information
Iku-turso committed Feb 10, 2022
1 parent e4b6f18 commit 7b13267
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,24 @@ describe('createContainer.error-monitoring-for-instantiation', () => {
}
});

it('triggers error monitoring for child', () => {
it('triggers error monitoring only for child', () => {
expect(errorMonitorMock.mock.calls).toEqual([
[
{
error: 'some-error',

context: [
{ id: 'some-parent-injectable' },
{ id: 'some-child-injectable' },
{
id: 'some-parent-injectable',
instantiationParameter:
'some-instantiation-parameter-for-parent',
},

{
id: 'some-child-injectable',
instantiationParameter:
'some-instantiation-parameter-for-child',
},
],
},
],
Expand Down Expand Up @@ -144,7 +153,7 @@ describe('createContainer.error-monitoring-for-instantiation', () => {
instantiateChildMock.reject(new Error('some-error'));
});

it('triggers error monitoring once for full relevant injection context', async () => {
it('triggers error monitoring only for child', async () => {
await actualPromise.catch(noop);

expect(errorMonitorMock.mock.calls).toEqual([
Expand All @@ -153,8 +162,17 @@ describe('createContainer.error-monitoring-for-instantiation', () => {
error: expect.any(Error),

context: [
{ id: 'some-parent-injectable' },
{ id: 'some-child-injectable' },
{
id: 'some-parent-injectable',
instantiationParameter:
'some-instantiation-parameter-for-parent',
},

{
id: 'some-child-injectable',
instantiationParameter:
'some-instantiation-parameter-for-child',
},
],
},
],
Expand All @@ -171,7 +189,7 @@ describe('createContainer.error-monitoring-for-instantiation', () => {
instantiateChildMock.reject('some-non-error-rejection');
});

it('triggers error monitoring once for full relevant injection context', async () => {
it('triggers error monitoring only for child', async () => {
await actualPromise.catch(noop);

expect(errorMonitorMock.mock.calls).toEqual([
Expand All @@ -180,8 +198,17 @@ describe('createContainer.error-monitoring-for-instantiation', () => {
error: 'some-non-error-rejection',

context: [
{ id: 'some-parent-injectable' },
{ id: 'some-child-injectable' },
{
id: 'some-parent-injectable',
instantiationParameter:
'some-instantiation-parameter-for-parent',
},

{
id: 'some-child-injectable',
instantiationParameter:
'some-instantiation-parameter-for-child',
},
],
},
],
Expand Down Expand Up @@ -214,8 +241,17 @@ describe('createContainer.error-monitoring-for-instantiation', () => {
error: 'some-non-error-rejection',

context: [
{ id: 'some-parent-injectable' },
{ id: 'some-child-injectable' },
{
id: 'some-parent-injectable',
instantiationParameter:
'some-instantiation-parameter-for-parent',
},

{
id: 'some-child-injectable',
instantiationParameter:
'some-instantiation-parameter-for-child',
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ const getInstance = ({
);
}

const newContext = [...oldContext, { id: injectable.id }];
const newContext = [
...oldContext,
{ id: injectable.id, instantiationParameter },
];

const injectableCausingCycle = pipeline(
oldContext,
Expand Down

0 comments on commit 7b13267

Please sign in to comment.