Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

describeWithDOM enhancement #126

Merged
merged 3 commits into from
Jan 21, 2016

Conversation

nfpiche
Copy link
Contributor

@nfpiche nfpiche commented Jan 19, 2016

Let me know how this looks, wasn't 100% sure on taking describeWithDOM out of index.js

mount,
} from '../';
import {
describeWithDOM,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/\t/ /g please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops, thought I caught those, will update

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb eslint should fail on these, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theoretically, but i haven't gotten around to these rules yet, so i don't know how they're configured :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually why I thought I got them all, the linter wasn't yelling at me anymore, so it doesn't appear to be catching them everywhere, because I was getting warnings in other places

@ljharb
Copy link
Member

ljharb commented Jan 19, 2016

Other than my comments, this looks awesome.

@ljharb
Copy link
Member

ljharb commented Jan 19, 2016

This LGTM! It'd be a semver-minor.

}

describeWithDOM.only = only;
describeWithDOM.skip = skip;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order to eliminate duplication, you could do smth like: (pseudo code)

function testSuite(register, title, fn) {
  describe('(uses jsdom)', () => {
    if (typeof jsdom === 'function') {
      jsdom();
      register(a, b);
    } else {
      // if jsdom isn't available, skip every test in this describe context
      describe.skip(a, b);
    }
  });
}

function only(title, fn) {
  testSuite(describe.only, title, fn);
}

function skip(title, fn) {
  testSuite(describe.skip, title, fn);
}

function describeWithDOM(title, fn) {
  testSuite(describe, title, fn);
}

@vesln
Copy link
Contributor

vesln commented Jan 20, 2016

As I stated in different PRs, I think we should take care of other mocha interfaces as well (out of scope for this pr obviously), but @nfpiche might be interested in exploring

@lelandrichardson
Copy link
Collaborator

For context, describeWithDOM will be removed from enzyme entirely in the 2.0 release. The idea behind it (refreshing the global document for each test) is inherently incompatible with React and causes lots of issues. We will be recommending a single document be used for your entire test-suite moving forward.

That said, I'm fine with merging this in for 1.x releases

"test:all": "npm run react:13 && npm test && npm run react:14 && npm test",
"test:describeWithDOMOnly": "mocha --compilers js:babel/register --recursive src/**/__tests__/describeWithDOM/describeWithDOMOnly-spec.js",
"test:describeWithDOMSkip": "mocha --compilers js:babel/register --recursive src/**/__tests__/describeWithDOM/describeWithDOMSkip-spec.js",
"test:all": "npm run react:13 && npm test && npm run test:describeWithDOMOnly && npm run test:describeWithDOMSkip && npm run react:14 && npm test && npm run test:describeWithDOMOnly && npm run test:describeWithDOMSkip",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused. Why exactly were these tests needed to be added separately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't technically need it for .skip, but I felt like having it be consistent would be the way to go. We do need a separate run for the .only tests though, otherwise it will skip the rest of the test suite. Happy to change things up a bit to be less verbose if you have an idea though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that's fine. I'm not 100% sure we even need to add tests for describeWithDOM, but since they're already added it's better than nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor New stuff.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants