chaijs / chai

BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
https://chaijs.github.io
MIT License
8.14k stars 698 forks source link

Plugin issues with Chai v4 #890

Closed meeber closed 6 years ago

meeber commented 7 years ago

I went through the popular Chai plugins to see how their test suites fair with Chai v4. (Actually, I used the #884 build instead of the current canary release). Overall, we're in good shape. Here are my findings:

  1. chai-immutable
  2. chai-jquery
  3. chai-react

Major issues

Minor issues

No issues

jeromemacias commented 7 years ago

Can you also include https://github.com/producthunt/chai-enzyme please ?

meeber commented 7 years ago

@jeromemacias Thanks for the heads up! Just ran the test suite with Chai v4; no issues.

lucasfcosta commented 7 years ago

Hey friends! So, is anything left here @meeber? We were thinking about releasing 4.0.0 and it would be good to avoid issues with any plugins.

All we've gotta do is make sure those PRs are merged when 4.0.0 gets released right?

meeber commented 7 years ago

There have been a number of commits in master since I tested these plugins. And we have a couple more on the way. I don't anticipate any new issues, but will need to test them again with the updated code for due diligence.

Assuming there aren't any additional issues: The plugins listed under "minor issues" already either have a PR ready to merge, or a PR that just needs the version updated once 4.0 is release, and then it can be merged. The plugins listed under "major issues" need more work. @astorije is already aware of some changes that impact chai-immutable. chai-things is broken since before v3.5 due to a conflict with Chai core regarding the any flag; I don't think it's essential that we fix this prior to v4.0 release, but it's something we should look into going forward.

keithamus commented 7 years ago

Development on chai-things has mostly stalled - in the current situation the featureset that chai-things really needs is not well catered for with chai's current plugin system. The proposed new system in https://github.com/chaijs/chai/issues/585 takes plugins like chai-things into account (hopefully).

meeber commented 7 years ago

@keithamus @vieiralucas @lucasfcosta @shvaikalesh @astorije I ran the test suites for all of these plugins using the second canary release. There were a couple of new small issues in dirty-chai and chai-query; I updated the PRs for those already. There was also a new breaking change in chai-immutable due to #924; I updated the PR for that as well.

Finally, there's a new issue related to #900 that's causing three test suites to fail. Haven't had a chance to look into it in-depth, but it appears that the issue is related to mocha-phantomjs choking on these lines. Specifically, Object.getOwnPropertyNames(testFn) is including callee in the result set, but then Object.getOwnPropertyDescriptor(testFn, name) is returning undefined when name is callee. That seems very odd; more investigation is needed. The affected repos are:

  1. chai-immutable
  2. chai-react
  3. chai-jquery
meeber commented 7 years ago

@keithamus @vieiralucas @lucasfcosta @shvaikalesh As mentioned above, several plugin test suites are failing in PhantomJS because of these lines:

var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
  return !Object.getOwnPropertyDescriptor(testFn, name).configurable;
});

I won't have enough cycles to troubleshoot this in depth for a couple weeks. If no one else does either, then I suggest we hack-fix it by checking that the return value of Object.getOwnPropertyDescriptor(testFn, name) is defined before accessing its .configurable property. Normally this shouldn't be necessary but something funky is clearly going on here; this hack should at least let the tests pass until we have a chance to investigate further.

meeber commented 7 years ago

Per #966, the PhantomJS 1.x issue is now resolved.

meeber commented 7 years ago
keithamus commented 7 years ago

I feel as though chai-things will pretty much have to wait until #585 before it can get the abilities it needs from chai (and also the attention).

meeber commented 7 years ago

When checking for compatibility with Chai v4, I was using each plugin's master branch. Per https://github.com/chaijs/chai-spies/issues/71, the current npm release of chai-spies is incompatible with Chai v4; we need to prioritize releasing a new version of that.

lucasfcosta commented 7 years ago

@meeber but according to what I've seen at that issue, chai-spies master branch is already compatible with Chai v4, right?

Also, I think that we should focus on releasing chai-as-promised too. I've been getting lots of requests to do that and I think that plugin is pretty important for our users.

I'm planning on releasing the v4 compatible versions of our plugins this sunday. If anyone wants to schedule a hangouts or a skype call so that we can get these done it would be awesome.

Also, I remember @keithamus sent us a link with instructions for releasing modules but I can't find it. It would be great if we could have that in order to get this going.

meeber commented 7 years ago

@lucasfcosta Right!

sverweij commented 7 years ago

There is a (easily solvable, but annoying) issue with chai-json-schema using chai@4 on node@4 - see https://github.com/chaijs/chai-json-schema/issues/47