question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do the test examples work?

See original GitHub issue

Hi Jared. I’m sorry I’m swamping you with issues at the moment

There are a couple of things about the text examples I’d like clarity on:

await tree.find(MyInnerForm).props().submitForm()

Using await here gives the impression that submitForm returns a promise, which is misleading (relevant lines). If you’re using async validations via validate or validationSchema then it’s going to return immediately before before executeSubmit is executed

Is it better to just use executeSubmit which is sync?

tree.find(MyInnerForm).update().dive()

I’m pretty new to Enzyme so found this confusing. Enzyme tells me I can only call update() on the root wrapper

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
codeincontextcommented, Aug 1, 2017

Those tests verify that the function gets called, not whether the await is blocking. I have a strong suspicion that the tests will still pass if you remove the ‘await’ keyword.

Here’s my failing test case:

Fails

  it('handles successful submission', async () => {
    const submitMock = () => Promise.resolve();
    const wrapper = shallow(<ReviewForm submitReview={submitMock} />);
    expect(wrapper.length).to.equal(1);

    const getForm = () => wrapper.update().find('InnerForm');
    const diveFind = query => wrapper.update().dive().find(query);

    await getForm().props().submitForm();

    expect(getForm().props().status).to.deep.equal({ success: true });
    expect(diveFind('Success').length).to.equal(1);
    expect(diveFind('form').length).to.equal(0);
  });

Passes

  it('handles successful submission', async () => {
    const submitMock = () => Promise.resolve();
    const wrapper = shallow(<ReviewForm submitReview={submitMock} />);
    expect(wrapper.length).to.equal(1);

    const getForm = () => wrapper.update().find('InnerForm');
    const diveFind = query => wrapper.update().dive().find(query);

    await getForm().props().submitForm();

    // Wait for yum validations to complete
    await new Promise(r => setImmediate(r));

    expect(getForm().props().status).to.deep.equal({ success: true });
    expect(diveFind('Success').length).to.equal(1);
    expect(diveFind('form').length).to.equal(0);
  });
0reactions
jaredpalmercommented, Oct 11, 2017

Move this discussion to #154

Read more comments on GitHub >

github_iconTop Results From Across the Web

7 Types of Pre-Employment Assessment Tests and Screenings
Learn more about the different types of pre-employment testing, including personality, skills and physical ability assessment tests and ...
Read more >
Pre-employment testing: a selection of popular tests - Workable
Pre-employment testing is a standardized method to test job candidates on their qualifications for a job during the recruitment process. These can range ......
Read more >
Personnel Selection: Methods: Work Sample Tests - HR-Guide
Work Sample tests are based on the premise that the best predictor of future behavior is observed behavior under similar situations.
Read more >
Screening by Means of Pre-Employment Testing - SHRM
This toolkit discusses the basics of pre-employment testing, types of selection tools and test methods, and determining what testing is needed.
Read more >
Examples of Pre-Employment Tests
Occupational Assessments. Occupational assessments measure an applicant's skills related to what the job requires and can include reading comprehension, math, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found