HOME

TheInfoList



OR:

Jest is a
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
testing framework built on top of
Jasmine Jasmine ( taxonomic name: ''Jasminum''; , ) is a genus of shrubs and vines in the olive family ( Oleaceae). It contains around 200 species native to tropical and warm temperate regions of Eurasia, Africa, and Oceania. Jasmines are widely cult ...
and maintained by Meta (formerly Facebook). It was designed and built by
Christoph Nakazawa Christoph is a male given name and surname. It is a German variant of Christopher. Notable people with the given name Christoph * Christoph Bach (1613–1661), German musician * Christoph Büchel (born 1966), Swiss artist * Christoph Dientzenhofe ...
with a focus on simplicity and support for large
web applications A web application (or web app) is application software that is accessed using a web browser. Web applications are delivered on the World Wide Web to users with an active network connection. History In earlier computing models like client-serve ...
. It works with projects using
Babel Babel is a name used in the Hebrew Bible for the city of Babylon and may refer to: Arts and media Written works Books *Babel (book), ''Babel'' (book), by Patti Smith * Babel (2012 manga), ''Babel'' (2012 manga), by Narumi Shigematsu * Babel (20 ...
,
TypeScript TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. It is designed for the development of large appl ...
,
Node.js Node.js is an open-source server environment. Node.js is cross-platform and runs on Windows, Linux, Unix, and macOS. Node.js is a back-end JavaScript runtime environment. Node.js runs on the V8 JavaScript Engine and executes JavaScript code ou ...
,
React REACT or React may refer to: Science and technology * REACT (telescope), a telescope at Fenton Hill Observatory, New Mexico, US Computing * React (JavaScript library) , a JavaScript library for building user interfaces, from Facebook ** React Nat ...
,
Angular Angular may refer to: Anatomy * Angular artery, the terminal part of the facial artery * Angular bone, a large bone in the lower jaw of amphibians and reptiles * Angular incisure, a small anatomical notch on the stomach * Angular gyrus, a region o ...
,
Vue.js Vue.js (commonly referred to as Vue; pronounced "view") is an open-source model–view–viewmodel front end JavaScript framework for building user interfaces and single-page applications. It was created by Evan You, and is maintained by him a ...
and
Svelte Svelte is a free and open-source front end component framework or language created by Rich Harris and maintained by the Svelte core team members. Svelte is not a monolithic JavaScript library imported by applications: instead, Svelte compiles H ...
. Jest doesn't require a lot of configuration for first-time users of a testing framework.


Usage and examples


Installation

Use the JavaScript package manager npm to install Jest in
Node.js Node.js is an open-source server environment. Node.js is cross-platform and runs on Windows, Linux, Unix, and macOS. Node.js is a back-end JavaScript runtime environment. Node.js runs on the V8 JavaScript Engine and executes JavaScript code ou ...
: $ npm install --save-dev jest


Example

In this example, we will write a test case for the following module saved as sum.js: function sum(a, b) module.exports = sum; Our test case will be in a file named sum.test.js for Jest to automatically pick it up as a test case for sum.js. The contents of the file with the test case will be: const sum = require('./sum'); test('adds 1 + 2 to equal 3', () => ); Then, from the command line, we run this command: $ npm run test This runs the test and outputs the corresponding result on the command line.


See also

*
List of unit testing frameworks This article is a list of tables of code-driven unit testing frameworks for various programming languages. Some, but not all, of these are based on xUnit. Columns (classification) * Name: This column contains the name of the framework and wi ...
*
Jasmine Jasmine ( taxonomic name: ''Jasminum''; , ) is a genus of shrubs and vines in the olive family ( Oleaceae). It contains around 200 species native to tropical and warm temperate regions of Eurasia, Africa, and Oceania. Jasmines are widely cult ...
*
Mocha Mocha may refer to: Places * Mocha Island, an island in Biobío Region, Chile * Mocha, Chile, a town in Chile * Mocha, Ecuador, a city in Ecuador * Mocha Canton, a government subdivision in Ecuador * Mocha, a segment of Kutiyana (Vidhan Sabha c ...
* npm *
QUnit QUnit is a JavaScript unit testing framework. Originally developed for testing jQuery, jQuery UI and jQuery Mobile, it is a generic framework for testing any JavaScript code. It supports client-side environments in web browsers, and server-s ...
* Unit.js *
JavaScript framework A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build an ...
*
JavaScript library A JavaScript library is a library of pre-written JavaScript code that allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies. Libraries With the expanded demands for JavaScript, an e ...


References


External links


GitHub repository

Jest documentation
{{JavaScript JavaScript libraries JavaScript programming tools Software using the MIT license JavaScript web frameworks