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

Fix firefox #20

Merged
merged 4 commits into from
Jun 15, 2021
Merged

Fix firefox #20

merged 4 commits into from
Jun 15, 2021

Conversation

olivierwilkinson
Copy link
Collaborator

closes #18

  • add Firefox to test setup
  • fix injecting DOM Testing Library on Firefox
  • fix using Regular Expressions on Firefox

Replace chromedriver with the wdio selenium standalone service to
support multiple drivers at once.

Add Firefox to the wdio.conf.js capabilities
Evaluating the UMD script is not enough to add TestingLibraryDom to the
window when running on Firefox. Add a script tag to the head element
with the UMD inlined to add TestingLibraryDom to the window.

Why it doesn't work is not clear to me right now so there may be a
better way of fixing this. I'm assuming this is a security feature of
Firefox but that is a guess.
DOM Testing Library uses instanceof to check whether a query is passed a
RegExp, a Function or a string arg. For some reason on Firefox when a
RegExp is passed to a query the `arg instanceof RegExp` check is always
false, resulting in RegExp arguments being treated like a string. It
appears that this is because the RegExp that is created in executeQuery
is not the same class as that used in the instanceof check in DTL.

I'm not sure exactly what could be causing it, it's possible that
this is due to a polyfill or how we are adding DTL to the page, or
something completely different.

Assigning the RegExp that is in scope in executeQuery to window.RegExp
seems to fix the problem, presumably because it overrides whatever
modified RegExp class was added by the UMD script.
@github-actions
Copy link

🎉 This PR is included in version 3.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

The library doesn't seem to be working with firefox
1 participant