Testing of Ethereum Mocha framework
to install the test tool Mocha NPM install gulp Mocha -- save dev
write test task
gulp. Task (& 39; test-api', function () {
return gulp.src(' test.js')< br /> .pipe(mocha())
.once(' error', function () {
process.exit(1);< br /> })
.once(' end', function () {
process.exit();< br /> });< br />});
write test cases in test.js
var assert = require (& quot; assert");< br />var rest = require(" restler");// Middleware used to request API interface
var apictrl = require (#)/ controllers/api');// API mole
var baseurl = & 39; http://localhost :9000/api';< br />describe(' this is description', function () {
it(' this is assert', function (done) {
rest.get(baseUrl + '/ testAPI/1'). on(' success', function (res) {
assert(res.result === 1);< br /> done();< br /> });< br /> });< br />});
the above is a simple use case to build a nodejs unit test. A brief description is to use the existing Mocha framework for unit testing, and then integrate the test environment through gulp to configure automatic test cases, so as to improve efficiency.
karma: a JavaScript test runner based on node.js. The tool can be used to test all mainstream web browsers, integrate into CI (continuous integration) tool, and also be used with other code editors. A powerful feature of this testing tool is that it can monitor the changes of files, then execute it by itself, and display the test results through console.log. A powerful feature of Karl is that it can monitor the transformation of a set of files and start testing the saved files immediately without leaving the text editor. Test results are usually displayed on the command line rather than in the code editor. This makes it possible for Karl to work with almost any JS editor
as for travis.ci, you can go to the community of zhuan podcast to see the related content of assertion library. Chuan official website = = > Community = = = & gt; Test section. There are a lot of dry goods that are very suitable for Xiao to see.
2. If it is installed on Disk C, open the computer after installation and input C: 92; ProgramData\ Imagineer Systems Ltd\ Click the "tools" menu to display the hidden files and folders
3_ pro_ v4_ If there is no such folder in the path, start the program once and then close it completely
4. Another cracking file "BSC. DLL" covers the original file in the "bin" folder in the installation directory.
if (mole = = true) {/ / if() condition is true before execution, but mole is not a condition
mole. Exports = login
} < / pre >
it's better to post the error content
1, jest
are well-known JavaScript unit test tools, which are open source and out of the box by Facebook. At the most basic level, it is designed to quickly and simply write native JavaScript tests, automatically simulate the commonjs mole returned by require (), and provides features including built-in test environment DOM API support, reasonable default value, preprocessing code and default execution of parallel tests. By running tests in parallel processes at the same time, the test can be finished faster< AVA
2. AVA is known as the "test runner of the future". It makes use of the advantage of JavaScript in node.js to make IO parallel, so that your tests can be executed concurrently, which is especially useful for heavy io tests. In addition, test files can run in parallel in different processes, so that each test file can get better performance and independent environment. Test concurrent execution forces you to write atomic tests, which means that tests don't need to rely on global state or the state of other tests
3. Mocha
a testing framework with rich functions, which is used for JavaScript application testing on node.js and browser, makes asynchronous testing simple and interesting. It can continuously run tests, support flexible and accurate reporting, and go to the correct test example when mapping to uncapped exceptions
4. The JavaScript test runner based on node.js is designed to provide an effective test environment for developers. It can be used to test all major web browsers, integrate into CI tools, and work with other code editors. Another powerful feature is that it can monitor the changes of files, then execute them by itself, and display the test results through console.log< Second, web testing
1) integration testing
enzyme
a JavaScript testing tool for react, which is convenient for you to judge, manipulate and experience the output of react components. Its API aims to make DOM operation and traversal very flexible and intuitive by imitating jQuery API. Compatible with all major test runners and judgment libraries
2) function test
1. Webdriverio
this library is the webdriver (browser automation) mole of node.js, which can write Super Simple selenium test in BDD / TDD test framework
2. Nightwatch
an easy-to-use browser automation testing solution based on node.js. It uses the powerful selenium webdriver API to execute commands and assertions on DOM elements. The syntax is simple but powerful, allowing you to write tests quickly. Built in command line test runner, can run overall test, group test or single test
3) visual test
storybook
a development environment for UI components, which allows you to browse the component library, view the different states of each component, and develop and test components interactively. It runs outside the application and allows isolated development of UI components, which can improve the reusability, testability and development speed of components
4) monkey testing (also known as "funny testing")
gremlins.js
a monkey testing library written in JavaScript for node.js and browsers. By releasing a large number of irregular gremlins to detect the robustness of web applications
5) server testing
1, K6
is a developer centered load testing tool for testing performance. It provides a fresh and easy-to-use script API that is choreographed through rest API. Using go and JavaScript to build can be well integrated into the development workflow
2. Supertest is an extension of SuperAgent, a lightweight HTTP Ajax request library. Provides a high degree of abstraction for HTTP testing, greatly simplifying the HTTP based testing.
the following is an example of using Mocha, which can run in node and browser
Mocha
Add Chai as an asset
karma + jasmine, mocha + should, jest and enzyme.
node.jsp>node.jse32771;- 34385;- mocha27979;- 3579797;- 26694;- 26550;
at least soft-name --save-dev
35013d;-2716922359;- 21040;- package.jsondevDependencies28857;
Should: https://github.com/tj/should.js
SuperAgent: https://github.com/visionmedia/superagent
Mocha: https://github.com/mochajs/mocha
http://mochajs.org/
(35013; e.g. install-g mocha
20196;: 20256; 21040; 26681;= 244051;
mocha --recursive --timeout 15000
webstom

node.jse32771;- 34385;- mocha27979;- 35797;- 26694;- 26550;
at least soft-name --save-dev
35013d;-271693;- 22359;- 21040;- package.jsondev Dependencies28857;
S hould:https http://github.com/tj/should.js
SuperA gent:https http://github.com/visionmedia/superagent
M ocha:https http://github.com/mochajs/mocha
http://mochajs.org/
(3) e.g. install-g mocha
20196;- 20256;- 21040;- 26681;- 24405;
mocha --recursive --timeout 15000
webstom

stable long-term support version: 6.10; Development preview version: 7.9
take a look at the version of node on your machine. You usually use the stable version. If it's lower than 6.10, download the latest stable version and install it. It should be able to solve the problem
if it's a Windows XP system, you don't have to worry about it. Node has stopped supporting Windows XP (of course, you can see the minimum version of node supported by mocha. If version 5. X is available, XP should still work. You can check the official website of node for details).
