@@ -62,7 +62,7 @@ when a real user uses it.
62
62
63
63
1 . A test runner or framework
64
64
2 . Specific to a testing framework (though we recommend Jest as our
65
- preference, the library works with any framework)
65
+ preference, the library works with any framework. See [ Using Without Jest ] ( #using-without-jest ) )
66
66
67
67
## Table of Contents
68
68
@@ -92,6 +92,7 @@ when a real user uses it.
92
92
- [ Debugging] ( #debugging )
93
93
- [ ` prettyDOM ` ] ( #prettydom )
94
94
- [ Implementations] ( #implementations )
95
+ - [ Using Without Jest] ( #using-without-jest )
95
96
- [ FAQ] ( #faq )
96
97
- [ Other Solutions] ( #other-solutions )
97
98
- [ Guiding Principles] ( #guiding-principles )
@@ -730,6 +731,37 @@ Implementations include:
730
731
- [` react-testing-library ` ](https :// github.com/kentcdodds/react-testing-library)
731
732
- [` pptr-testing-library ` ](https :// github.com/patrickhulce/pptr-testing-library)
732
733
734
+ ## Using Without Jest
735
+
736
+ If you ' re running your tests in the browser bundled with webpack (or similar)
737
+ then ` dom-testing-library ` should work out of the box for you . However , most
738
+ people using ` dom-testing-library ` are using it with
739
+ [the Jest testing framework ](https :// jestjs.io/) with the `testEnvironment`
740
+ set to [` jest-environment-jsdom ` ](https :// www.npmjs.com/package/jest-environment-jsdom)
741
+ (which is the default configuration with Jest ).
742
+
743
+ [jsdom ](https :// github.com/jsdom/jsdom) is a pure JavaScript implementation
744
+ of the DOM and browser APIs that runs in node . If you ' re not using Jest and
745
+ you would like to run your tests in Node , then you must install jsdom yourself .
746
+ There ' s also a package called
747
+ [jsdom -global ](https :// github.com/rstacruz/jsdom-global) which can be used
748
+ to setup the global environment to simulate the browser APIs .
749
+
750
+ First , install jsdom and jsdom -global .
751
+
752
+ ` ` `
753
+ npm install --save-dev jsdom jsdom-global
754
+ ` ` `
755
+
756
+ With mocha , the test command would look something like this :
757
+
758
+ ` ` `
759
+ mocha --require jsdom-global/register
760
+ ` ` `
761
+
762
+ > Note , depending on the version of Node you ' re running, you may also need to install
763
+ > ` @babel/polyfill ` (if you ' re using babel 7) or `babel-polyfill` (for babel 6).
764
+
733
765
## FAQ
734
766
735
767
<details >
0 commit comments