diff --git a/docs/vue-testing-library/setup.mdx b/docs/vue-testing-library/setup.mdx index d03e3c0ed..4b35edfe1 100644 --- a/docs/vue-testing-library/setup.mdx +++ b/docs/vue-testing-library/setup.mdx @@ -3,4 +3,47 @@ id: setup title: Setup --- -`Vue Testing Library` does not require any configuration to be used. +`Vue Testing Library` does not require any configuration to be used. However, +there are some things you can do when configuring your testing framework to +reduce some boilerplate. In these docs we'll demonstrate configuring Jest, but +you should be able to do similar things with +[any testing framework](#using-without-jest) (Vue Testing Library does not +require that you use Jest). + +## Using without Jest + +If you're running your tests in the browser bundled with webpack (or similar) +then `Vue Testing Library` should work out of the box for you. However, most +people using Vue Testing Library are using it with the Jest testing framework +with the `testEnvironment` set to `jest-environment-jsdom` (which is the default +configuration with Jest). + +`jsdom` is a pure JavaScript implementation of the DOM and browser APIs that +runs in Node. If you're not using Jest and you would like to run your tests in +Node, then you must install jsdom yourself. There's also a package called +`jsdom-global` which can be used to setup the global environment to simulate the +browser APIs. + +First, install `jsdom` and `jsdom-global`. + +``` +npm install --save-dev jsdom jsdom-global +``` + +With mocha, the test command would look something like this: + +``` +mocha --require jsdom-global/register +``` + +### Skipping Auto Cleanup + +[`Cleanup`](api.mdx#cleanup) is called after each test automatically by default +if the testing framework you're using supports the `afterEach` global (like +mocha, Jest, and Jasmine). However, you may choose to skip the auto cleanup by +setting the `VTL_SKIP_AUTO_CLEANUP` env variable to 'true'. You can do this with +[`cross-env`](https://github.com/kentcdodds/cross-env) like so: + +``` +cross-env VTL_SKIP_AUTO_CLEANUP=true jest +```