Archi's Academy

GetStarted

GetStarted
Get in touch

Automation

Testing

Mocha is a framework designed to test pages in web browsers. Mocha has a rich environment for constructing user interfaces in a browser. It is a testing framework for JavaScript running on Node.js.

Mocha uses HTML with the constructs in languages like C++ and Java. It mostly resembles Java because of the constructs like if, for, and while. But when you deep down into it, it starts to look like much more HTML because of the user interface constructs. Mocha runs on web browsers and servers. You can use Mocha to run both the browser and server cooperatively. Mocha is used by software engineers who design and develop web pages with dynamic content.

Hooks in Mocha: There are namely six hooks used in the testing by this framework to set up or load up preconditions used in the testing.

it()

describe()

beforeEach()

afterEach()

before()

after()

It is easy to learn and effective to use in your testing environments.

Mocha can be used with most JavaScript assertion libraries, including:

should.js

express.js

chai

better-assert

unexpected

Why we need it?

For:

Write tests for the required software functionality

Run the tests for the software functionality

Implement the software functionality

Repeat the cycle for any new functionality

Fix bugs and refactor until all tests pass

archis-trainees-blog

Arya Tuba Durgun

Wednesday, Mar 17, 2021