How to use the single-spa.registerApplication function in single-spa

To help you get started, we’ve selected a few single-spa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CanopyTax / single-spa / spec / apps / invalid-load-function / invalid-load-function.spec.js View on Github external
it('Dies if the load function returns a non-thenable object', () => {
    function loadFunction() {
      // return nothing
    }
    singleSpa.registerApplication('invalid-load-3', loadFunction, location => location.hash === "#invalid-load-function");

    location.hash = "#invalid-load-function";

    return singleSpa
      .triggerAppChange()
      .then(() => {
        expect(errs.length).toBeGreaterThan(0);
        expect(errs[0].appName).toBe('invalid-load-3');
        expect(errs[0].message.indexOf('single-spa loading function did not return a promise. Check the second argument to registerApplication')).toBeGreaterThan(-1)
        expect(singleSpa.getAppStatus('invalid-load-3')).toBe(singleSpa.SKIP_BECAUSE_BROKEN);
      })
  });
github CanopyTax / single-spa / spec / apps / invalid-load-function / invalid-load-function.spec.js View on Github external
it('Dies if the load function returns nothing', () => {
    function loadFunction() {
      // return nothing
    }
    singleSpa.registerApplication('invalid-load-1', loadFunction, location => location.hash === "#invalid-load-function");

    location.hash = "#invalid-load-function";

    return singleSpa
      .triggerAppChange()
      .then(() => {
        expect(errs.length).toBeGreaterThan(0);
        expect(errs[0].appName).toBe('invalid-load-1');
        expect(errs[0].message.indexOf('single-spa loading function did not return a promise. Check the second argument to registerApplication')).toBeGreaterThan(-1)
        expect(singleSpa.getAppStatus('invalid-load-1')).toBe(singleSpa.SKIP_BECAUSE_BROKEN);
      })
  });
github pingcap / tidb-dashboard / ui / dashboardApp / index.ts View on Github external
apiClient.init()
  await telemetry.init()

  const registry = new AppRegistry(options)

  singleSpa.registerApplication(
    'layout',
    AppRegistry.newReactSpaApp(() => LayoutMain, 'root'),
    () => {
      return !routing.isSignInPage()
    },
    { registry }
  )

  singleSpa.registerApplication(
    'signin',
    AppRegistry.newReactSpaApp(() => LayoutSignIn, 'root'),
    () => {
      return routing.isSignInPage()
    },
    { registry }
  )

  registry
    .register(AppDebugPlayground)
    .register(AppDashboardSettings)
    .register(AppUserProfile)
    .register(AppOverview)
    .register(AppKeyViz)
    .register(AppStatement)
    .register(AppClusterInfo)
github CanopyTax / single-spa / spec / apis / unregister-application.spec.js View on Github external
it(`should remove the application so it can be re-registered`, () => {
    singleSpa.registerApplication('about to unregister', app, () => false)
    expect(singleSpa.getAppStatus('about to unregister')).toBeTruthy()
    expect(() => {
      singleSpa.registerApplication('about to unregister', app, () => false)
    }).toThrow()

    return window.__SINGLE_SPA_DEVTOOLS__.exposedMethods.unregisterApplication('about to unregister').then(() => {
      expect(singleSpa.getAppStatus('about to unregister')).toBeFalsy()
    })
  })
})
github CanopyTax / single-spa / spec / parcels / parcel-mounts-parcel.spec.js View on Github external
it('can mount a parcel as a child of a parcel and unmount both together', () => {
    const app = createApp();
    let shouldAppBeMounted = true;

    singleSpa.registerApplication('parcel-mounts-parcels', app, () => shouldAppBeMounted);

    return singleSpa
      .triggerAppChange()
      .then(() => {
        expect(app.mountCalls).toBe(1);

        const parcelConfig1 = createParcelConfig();
        const parcelConfig2 = createParcelConfig();
        const parcel1 = app.mountProps.mountParcel(parcelConfig1, {domElement: document.createElement('div')})

        return parcel1
          .mountPromise
          .then(() => {
            expect(parcelConfig1.bootstrapCalls).toBe(1);
            expect(parcelConfig1.mountCalls).toBe(1);
            expect(parcelConfig1.unmountCalls).toBe(0);
github CanopyTax / single-spa / spec / apis / first-mount.spec.js View on Github external
it(`fires first-mount exactly once when the first app is mounted`, () => {
    singleSpa.registerApplication('firstMount', dummyApp, () => {
      return window.location.hash.indexOf('#/firstMount') === 0;
    });
    singleSpa.start();
    let numFirstMounts = 0, numBeforeFirstMounts = 0;

    window.addEventListener('single-spa:first-mount', () => {
      numBeforeFirstMounts++;
    });

    window.addEventListener('single-spa:first-mount', () => {
      numFirstMounts++;
    });

    window.location.hash = `#/firstMount`;

    return singleSpa
github CanopyTax / single-spa / spec / apps / unmount-rejects / unmount-rejects.spec.js View on Github external
beforeAll(() => {
    singleSpa.registerApplication('./unmount-rejects.app.js', () => import('./unmount-rejects.app.js'), location => location.hash === activeHash);
    singleSpa.start();
  });
github CanopyTax / single-spa / spec / apps / invalid-unload / invalid-unload.spec.js View on Github external
beforeAll(() => {
    singleSpa.registerApplication('./invalid-unload.app.js', () => import('./invalid-unload.app.js'), location => location.hash === activeHash);
    singleSpa.start();
  });
github CanopyTax / single-spa / spec / apps / invalid-bootstrap / invalid-bootstrap.spec.js View on Github external
beforeAll(() => {
    singleSpa.registerApplication('./invalid-bootstrap.app.js', () => import('./invalid-bootstrap.app.js'), location => location.hash === activeHash);
    singleSpa.start();
  });
github CanopyTax / single-spa / spec / apps / mount-rejects / mount-rejects.spec.js View on Github external
beforeAll(() => {
    singleSpa.registerApplication('./mount-rejects.app.js', () => import('./mount-rejects.app.js'), location => location.hash === activeHash);
    singleSpa.start();
  });