@@ -3,4 +3,47 @@ id: setup
3
3
title : Setup
4
4
---
5
5
6
- ` Vue Testing Library ` does not require any configuration to be used.
6
+ ` Vue Testing Library ` does not require any configuration to be used. However,
7
+ there are some things you can do when configuring your testing framework to
8
+ reduce some boilerplate. In these docs we'll demonstrate configuring Jest, but
9
+ you should be able to do similar things with
10
+ [ any testing framework] ( #using-without-jest ) (Vue Testing Library does not
11
+ require that you use Jest).
12
+
13
+ ## Using without Jest
14
+
15
+ If you're running your tests in the browser bundled with webpack (or similar)
16
+ then ` Vue Testing Library ` should work out of the box for you. However, most
17
+ people using Vue Testing Library are using it with the Jest testing framework
18
+ with the ` testEnvironment ` set to ` jest-environment-jsdom ` (which is the default
19
+ configuration with Jest).
20
+
21
+ ` jsdom ` is a pure JavaScript implementation of the DOM and browser APIs that
22
+ runs in Node. If you're not using Jest and you would like to run your tests in
23
+ Node, then you must install jsdom yourself. There's also a package called
24
+ ` jsdom-global ` which can be used to setup the global environment to simulate the
25
+ browser APIs.
26
+
27
+ First, install ` jsdom ` and ` jsdom-global ` .
28
+
29
+ ```
30
+ npm install --save-dev jsdom jsdom-global
31
+ ```
32
+
33
+ With mocha, the test command would look something like this:
34
+
35
+ ```
36
+ mocha --require jsdom-global/register
37
+ ```
38
+
39
+ ### Skipping Auto Cleanup
40
+
41
+ [ ` Cleanup ` ] ( api.mdx#cleanup ) is called after each test automatically by default
42
+ if the testing framework you're using supports the ` afterEach ` global (like
43
+ mocha, Jest, and Jasmine). However, you may choose to skip the auto cleanup by
44
+ setting the ` VTL_SKIP_AUTO_CLEANUP ` env variable to 'true'. You can do this with
45
+ [ ` cross-env ` ] ( https://github.com/kentcdodds/cross-env ) like so:
46
+
47
+ ```
48
+ cross-env VTL_SKIP_AUTO_CLEANUP=true jest
49
+ ```
0 commit comments