How to use the jest.expect function in jest

To help you get started, we’ve selected a few jest 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 SayMoreX / saymore-x / test / e2e / SaylessRunner.ts View on Github external
public async shouldExist(selector: string, log?: string) {
    //const element = await this.app.client.element(selector);
    const exists = await this.app.client.waitForExist(selector, 2 * 1000);

    if (exists) {
      // console.log(log ? log : `Found element matching '${selector}'`);
    } else {
      console.log(log ? log : `Could not find element matching '${selector}'`);
      throw new Error(`Could not find element matching '${selector}'`);
    }
    expect(exists).toBe(true);
  }
github SayMoreX / saymore-x / test / e2e / SaylessRunner.ts View on Github external
public async shouldNotExist(selector: string, log?: string) {
    //const element = await this.app.client.element(selector);
    const exists = await this.app.client.isExisting(selector);

    // if (exists) {
    //   throw new Error(`Should not have found element matching '${selector}'`);
    // }
    expect(exists).toBe(false);
  }
github SayMoreX / saymore-x / test / e2e / SaylessRunner.ts View on Github external
public async clickMenu(menuName: string, item: string) {
    await delay(500);
    const menu = await menuAddon.getMenuItem(menuName, item);
    expect(menu).toBeTruthy();
    //await this.app.electron.ipcRenderer.send("click-menu", [menuName, item]);
    await menuAddon.clickMenu(menuName, item);
  }
github SayMoreX / saymore-x / test / e2e / SaylessRunner.ts View on Github external
public async expectWindowTitle(title: string, log?: string) {
    await delay(500);
    const t = await this.app.browserWindow.getTitle();
    expect(t).toBe(title);
  }
github TeamHive / nestjs-seed / src / app / modules / users / user.controller.spec.ts View on Github external
it('should return an array of users', async () => {
            const result = ['test'];
            jest.spyOn(userService, 'findAll').mockImplementation(() => result);

            expect(await userController.findAll()).toBe(result);
        });
    });