• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nestjs / nest / 4985bf1d-5e80-46f6-bbaf-e681bc066260

03 Apr 2025 08:01AM UTC coverage: 89.274% (-0.03%) from 89.308%
4985bf1d-5e80-46f6-bbaf-e681bc066260

Pull #14900

circleci

kamilmysliwiec
feat(core): call hooks by components hierarchy level
Pull Request #14900: feat(core): call hooks by components hierarchy level (order)

2685 of 3377 branches covered (79.51%)

66 of 72 new or added lines in 9 files covered. (91.67%)

1 existing line in 1 file now uncovered.

7166 of 8027 relevant lines covered (89.27%)

16.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.42
/packages/core/hooks/utils/get-instances-grouped-by-hierarchy-level.ts
1
import { InjectionToken } from '@nestjs/common';
2
import { InstanceWrapper } from '../../injector/instance-wrapper';
3

4
export function getInstancesGroupedByHierarchyLevel(
1✔
5
  ...collections: Array<
6
    | Map<InjectionToken, InstanceWrapper>
7
    | Array<[InjectionToken, InstanceWrapper]>
8
  >
9
): Map<number, unknown[]> {
10
  const groupedByHierarchyLevel = new Map<number, unknown[]>();
12✔
11

12
  for (const collection of collections) {
12✔
13
    for (const [_, wrapper] of collection) {
48✔
14
      if (!wrapper.isDependencyTreeStatic()) {
53!
NEW
15
        continue;
×
16
      }
17

18
      const level = wrapper.hierarchyLevel;
53✔
19
      if (!groupedByHierarchyLevel.has(level)) {
53✔
20
        groupedByHierarchyLevel.set(level, []);
19✔
21
      }
22

23
      const byHierarchyLevelGroup = groupedByHierarchyLevel.get(level);
53✔
24
      if (wrapper.isTransient) {
53!
NEW
25
        const staticTransientInstances = wrapper
×
26
          .getStaticTransientInstances()
NEW
27
          .filter(i => !!i)
×
NEW
28
          .map(i => i.instance);
×
NEW
29
        byHierarchyLevelGroup!.push(...staticTransientInstances);
×
NEW
30
        continue;
×
31
      }
32

33
      if (wrapper.instance) {
53✔
34
        byHierarchyLevelGroup!.push(wrapper.instance);
41✔
35
      }
36
    }
37
  }
38

39
  return groupedByHierarchyLevel;
12✔
40
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc