Skip to content

v0.2.0

Compare
Choose a tag to compare
@github-actions github-actions released this 25 Mar 00:44
· 718 commits to main since this release
d21b235

Minor Changes

  • 064e5b4 #48 Thanks @calebeby! - - Add user.type method

    • Add actionability checks: visible and attached
  • beb1914 #43 Thanks @calebeby! - Provide a helpful message if the user forgets to use await.

    For example, if a user forgets to use await in the jest-dom assertion:

    test(
      'example',
      withBrowser(async ({ screen, utils }) => {
        await utils.injectHTML('<button>Hi</button>');
        const button = await screen.getByText(/hi/i);
        expect(button).toBeVisible();
      }),
    );

    Then a useful error message is produced:

    Cannot execute assertion toBeVisible after test finishes. Did you forget to await?
    
      103 |     await utils.injectHTML('<button>Hi</button>');
      104 |     const button = await screen.getByText(/hi/i);
    > 105 |     expect(button).toBeVisible();
          |                    ^
      106 |   }),
      107 | );
      108 |
    

    This is also handled for utility functions, user methods, and Testing Library queries.

  • 732fbff #45 Thanks @calebeby! - Now it is possible to pass variables to the browser in runJS:

    import { withBrowser } from 'test-mule';
    
    test(
      'runJS example with argument',
      withBrowser(async ({ utils, screen }) => {
        // element is an ElementHandle (pointer to an element in the browser)
        const element = await screen.getByText(/button/i);
        // we can pass element into runJS and the default exported function can access it as an Element
        await utils.runJS(
          `
            export default (element) => console.log(element);
          `,
          [element],
        );
      }),
    );