Member Junction
    Preparing search index...
    • Install a fake GLOBAL provider for DOM specs of data-bound components that load through the process-global provider rather than an injectable @Input() Provider — i.e. components that call a bare new RunView() (which reads RunView.Provider) and/or new Metadata() / Metadata.Provider (EntityByName, GetEntityObject).

      Call ONCE at the top of a describe. It registers beforeEach/afterEach to save and restore BOTH globals (RunView.Provider and Metadata.Provider) so nothing leaks into other tests, and returns an install function you call — typically inside a per-test render helper — to swap in a fake whose RunView/RunViews return your canned rows. The fake is exactly what createFakeProvider builds, so the options are identical.

      PREFER passing createFakeProvider(...) through the component's [Provider] input when the component reads ProviderToUse. Use this only for components that reach the GLOBAL provider and that you do not want to refactor — the save/restore is what keeps the global swap safe. See guides/ANGULAR_TESTING_GUIDE.md.

      Type Parameters

      • T = unknown

      Returns (options?: FakeProviderOptions<T>) => IMetadataProvider

      describe('MyDataComponent (DOM)', () => {
      const installProvider = useFakeGlobalProvider();

      it('renders the loaded rows', async () => {
      installProvider({ runViewResults: ROWS });
      const f = renderComponentFixture(MyDataComponent);
      await new Promise((r) => setTimeout(r, 0)); // let the async ngOnInit load settle
      f.detectChanges();
      expect(queryAll(f, '.row').length).toBe(ROWS.length);
      });
      });