How to use the @jupyterlab/testutils.expectFailure function in @jupyterlab/testutils

To help you get started, we’ve selected a few @jupyterlab/testutils 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 jupyterlab / jupyterlab / tests / test-services / src / kernel / ikernel.spec.ts View on Github external
it('should fail if the kernel is dead', async () => {
      const tester = new KernelTester();
      const kernel = await tester.start();

      // Create a promise that resolves when the kernel's status changes to dead
      const dead = testEmission(kernel.statusChanged, {
        find: () => kernel.status === 'dead'
      });
      tester.sendStatus(UUID.uuid4(), 'dead');
      await dead;
      await expectFailure(kernel.interrupt(), 'Kernel is dead');
      tester.dispose();
    });
  });
github jupyterlab / jupyterlab / tests / test-services / src / session / session.spec.ts View on Github external
it('should fail for wrong response status', async () => {
      const sessionModel = createSessionModel();
      const serverSettings = getRequestHandler(200, sessionModel);
      const options = createSessionOptions(sessionModel, serverSettings);
      const sessionPromise = Session.startNew(options);
      await expectFailure(sessionPromise);
    });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / ikernel.spec.ts View on Github external
it('should throw an error for an error response', async () => {
      handleRequest(defaultKernel, 500, {});
      const shutdown = defaultKernel.shutdown();
      await expectFailure(shutdown, '');
    });
github jupyterlab / jupyterlab / tests / test-services / src / config / config.spec.ts View on Github external
it('should fail for an incorrect response', async () => {
      const serverSettings = getRequestHandler(201, {});
      const configPromise = ConfigSection.create({
        name: randomName(),
        serverSettings
      });
      await expectFailure(configPromise, 'Invalid response: 201 Created');
    });
  });
github jupyterlab / jupyterlab / tests / test-services / src / session / isession.spec.ts View on Github external
it('should fail if the session is disposed', async () => {
        const session = Session.connectTo(defaultSession.model);
        session.dispose();
        await expectFailure(session.shutdown(), 'Session is disposed');
      });
github jupyterlab / jupyterlab / tests / test-services / src / session / isession.spec.ts View on Github external
it('should fail for improper model', async () => {
        handleRequest(defaultSession, 200, {});
        await expectFailure(defaultSession.setName(UUID.uuid4()));
      });
github jupyterlab / jupyterlab / tests / test-services / src / contents / index.spec.ts View on Github external
it('should fail for an incorrect response', async () => {
      handleRequest(contents, 204, DEFAULT_FILE);
      const save = contents.save('/foo', { type: 'file', name: 'test' });
      await expectFailure(save, 'Invalid response: 204 No Content');
    });
  });
github jupyterlab / jupyterlab / tests / test-services / src / kernelspec / kernelspec.spec.ts View on Github external
it('should handle an improper name', async () => {
      const R_SPEC = JSON.parse(JSON.stringify(PYTHON_SPEC));
      R_SPEC.name = 1;
      const serverSettings = getRequestHandler(200, {
        default: 'R',
        kernelspecs: { R: R_SPEC }
      });
      const promise = KernelSpecAPI.getSpecs(serverSettings);
      await expectFailure(promise, 'No valid kernelspecs found');
    });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should throw an error for an invalid response', async () => {
      const settings = getRequestHandler(201, {});
      const promise = Kernel.listRunning(settings);
      await expectFailure(promise, 'Invalid response: 201 Created');
    });
github jupyterlab / jupyterlab / tests / test-services / src / kernel / kernel.spec.ts View on Github external
it('should throw an error for an invalid response', async () => {
      const data = { id: UUID.uuid4(), name: 'foo' };
      const serverSettings = getRequestHandler(200, data);
      const kernelPromise = Kernel.startNew({ serverSettings });
      await expectFailure(kernelPromise, 'Invalid response: 200 OK');
    });