Some people say that front-end automated testing is very difficult, and I think it does. In the project, I personally do not feel comfortable writing tests, or to manually test. However, when we write the demo, we can use the automated test at all times.
Traditional Demo
1, create a new HTML
2, write JS script
3, run HTML
Usually write demo, The big guys are probably this step, in fact, we can use Karma automation this process.
Automated demo (using Karma)
Assuming you have installed the karma, if not, please see my blog Karma Unit test get started
1, running in root directory
Karma Init
All the way to the space select default, at what's the location of your source and test files? This entry *.js, other default
2, create a new JS file in the root directory demo.js
such as netizens an example:
function F (A, B, c) { alert (arguments.length); // Result: "2" A = +; Alert (arguments[0]); // Result: " Arguments[0] = "Qqyumidi"; alert (a); // Result: "Qqyumidi" alert (c); // result: "Undefined" c =; Alert (arguments[2]); // result: "Undefined" }f (1, 2);
3, run
Karma Start
At the command line you can see the results of the operation:
Feeling trouble?
This is my teaching, so write more wordy, I myself in the test when all kinds of quick and good!
Why don't you use Jasmine's grammar?
Of course, those describe grammar can be used, this example is just for teaching, so try to avoid interfering factors.
Use Karma test to write a small demo (arguments for example)