0% found this document useful (0 votes)
22 views10 pages

JavaScript Unit Testing and Linting Guide

The document discusses unit testing, emphasizing its importance in ensuring individual components of an application function as intended, typically using frameworks like Jest and Mocha. It also covers code coverage as a metric for assessing the extent of application testing and highlights the significance of code linting in improving code quality through automated error checking. Tools like ESLint are mentioned as essential for integrating linting into development workflows.

Uploaded by

Osman Sajid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views10 pages

JavaScript Unit Testing and Linting Guide

The document discusses unit testing, emphasizing its importance in ensuring individual components of an application function as intended, typically using frameworks like Jest and Mocha. It also covers code coverage as a metric for assessing the extent of application testing and highlights the significance of code linting in improving code quality through automated error checking. Tools like ESLint are mentioned as essential for integrating linting into development workflows.

Uploaded by

Osman Sajid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Code Formatting and

Testing

David Tucker
CTO Consultant

@_davidtucker_ | [Link]
Unit Testing
Unit testing is where individual components (or "units") of an application are
tested to make sure they behave as the author intended. These tests are
usually written for a specific unit testing framework. It is common for these
tests to get executed every time code is committed to a project to ensure
the new code does not break application functionality.

Unit testing is just one type of testing that complex software projects may
leverage.
Jest

Mocha

Jasmine JavaScript Testing Frameworks


AVA

Vitest
More Information
JavaScript Unit Testing with Jest
Gabriel McNeilly
Code Coverage
Code Coverage is a metric designed to tell you how much of an application
is actually tested by the collection of unit tests that have been written for it.
While there are different approaches for calculating this metric, it is
generally assumed that a higher code coverage number is better than a
lower one as it means more of the application is tested by the unit tests.
Code Linting and Formatting
Code Linting
Linting is the automated checking of your source code for programmatic
and stylistic errors. This is done by using a lint tool (otherwise known as
linter). A lint tool is a basic static code analyzer Linting is important to
reduce errors and improve the overall quality of your code. Using lint tools
can help you accelerate development and reduce costs by finding errors
earlier.

Bellairs, Richard. "What is Lint Code? And What is Linting and Why is Linting Important." Perforce. [Link]
...
[Link]

“ESLint statically analyzes your


code to quickly find problems. It
is built into most text editors and
you can run ESLint as part of your
continuous integration pipeline.”
[Link]

“ESLint statically analyzes your


code to quickly find problems. It
is built into most text editors and
you can run ESLint as part of your
continuous integration pipeline.”
Next Steps

You might also like