Recently, when I wrote the single test, I found that, gee, how can the single test not watch? Consistency This command error! Ah, how can my component introduce a single test mount error? Off to a bad start…
Problem 1 has an errortoo many open files
Yarn test x.test.js –watch: yarn test x.test.js –watch: yarn test x.test.js –watch: yarn test x.test.js –watch: yarn test x.test.js –watch
This problem is caused by Mac OSX’s limit on the number of open files.
Method 1: We can modify the open file limit through the terminal
// Check the current limit
1. launchctl limit
// Modify the maxFiles limit
2. sudo launchctl limit maxfiles 1024 unlimited
Copy the code
Method 2: Modify the JEST configuration, either of the following two
// Add the 'roots' configuration
roots: ["test/unit"].// Add 'watchPathIgnorePatterns'
watchPathIgnorePatterns: ['node_modules'].Copy the code
Question 2: Failed when running a single test
Why did I get an error when running a single test? Single test introduced a mount component… What ghost…
Does the component define a name attribute? There’s a pattern error here, right? The big ye… I just emptied the component contents and wrote a simple div, which was pretty damn good. It’s really component problems, self-doubt…
// Single test code this little bit, my component must be 🆗! Self-confidence!
describe('a component'.() = > {
test('a'.() = > {
const wrapper = mount(a)
console.log(wrapper); })})Copy the code
$route.name = $route.name = $route.name = $route. Rookie me, vomiting blood.