Skip to content

Instantly share code, notes, and snippets.

@BenBrostoff
Last active August 11, 2019 19:23
Show Gist options
  • Save BenBrostoff/934bb121200a78227578967b1a85494d to your computer and use it in GitHub Desktop.
Save BenBrostoff/934bb121200a78227578967b1a85494d to your computer and use it in GitHub Desktop.

Revisions

  1. BenBrostoff revised this gist Aug 11, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions test-sync-act.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    it('should render with the correct text without act', async () => {
    it('should render with the correct text without act', () => {
    ReactDOM.render(<App/>, el);
    expect(el.innerHTML).toContain('unloaded val');
    });

    it('should render with the correct text with act', async () => {
    it('should render with the correct text with act', () => {
    act(() => {
    ReactDOM.render(<App/>, el);
    });
  2. BenBrostoff created this gist Aug 11, 2019.
    11 changes: 11 additions & 0 deletions test-sync-act.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    it('should render with the correct text without act', async () => {
    ReactDOM.render(<App/>, el);
    expect(el.innerHTML).toContain('unloaded val');
    });

    it('should render with the correct text with act', async () => {
    act(() => {
    ReactDOM.render(<App/>, el);
    });
    expect(el.innerHTML).toContain('sync val');
    });