simplesmiler / vue-clickaway

Reusable clickaway directive for reusable Vue.js components
MIT License
963 stars 77 forks source link

Write tests #3

Open simplesmiler opened 8 years ago

simplesmiler commented 8 years ago

Research how does vue do unit tests.

Write tests for:

onomojo commented 6 years ago

👍

kris-luminar commented 6 years ago

I'm looking into writing some tests for this repo.

Was thinking Avoriaz might be a good testing library for this repo because it would allow us to fire up a mini Vue app in test, include vue-clickaway in a component and verify when clicking away from that component that away click handler fired. Hopefully, nothing much more complex than this example: https://github.com/eddyerburgh/avoriaz#assert-method-is-called-when-dom-event-is-triggered .

When I followed Avoriaz's instructions for installing itself, npm gave me warnings about needing peer dependencies.

± |add-unit-tests ✓| → npm install --save-dev avoriaz
npm WARN vue-clickaway@2.2.2 requires a peer of vue@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN avoriaz@6.3.0 requires a peer of vue@2.x but none is installed. You must install peer dependencies yourself.
npm WARN avoriaz@6.3.0 requires a peer of vue-template-compiler@^2.x but none is installed. You must install peer dependencies yourself.

+ avoriaz@6.3.0
added 217 packages in 4.39s

For lack of any better ideas about how to address these warnings I installed Vue.

± |add-unit-tests U:2 ✗| → npm install --save-dev vue
npm WARN avoriaz@6.3.0 requires a peer of vue-template-compiler@^2.x but none is installed. You must install peer dependencies yourself.

+ vue@2.5.16
added 1 package in 1.977s

In for a dime, in for a dollar, I guess, so installed vue-template-compiler.

± |add-unit-tests U:2 ✗| → npm install --save-dev vue-template-compiler
+ vue-template-compiler@2.5.16
added 3 packages in 2.417s

So now I've got all this:

@ package.json:18 @
     "loose-envify": "^1.2.0"
   },
   "devDependencies": {
+    "avoriaz": "^6.3.0",
     "eslint": "^1.10.3",
     "mkdirp": "^0.5.1",
     "rollup": "^0.21.2",
     "rollup-plugin-replace": "^1.1.0",
-    "uglify-js": "^2.6.1"
+    "uglify-js": "^2.6.1",
+    "vue": "^2.5.16",
+    "vue-template-compiler": "^2.5.16"
   },
   "homepage": "https://github.com/simplesmiler/vue-clickaway",
   "keywords": [

Do I actually need these as dev dependencies in order to write some tests?

Is Avoriaz worth pursuing or is that too high of a level testing framework for this repo?

fakefarm commented 6 years ago

Working with @kris-luminar on #28. Feel free to chime in over there if you have comments, questions, or suggestions. Thanks

kris-luminar commented 6 years ago

Turns out vue/test-utils is what we're supposed to be using now, not Avoriaz.