FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Getting Started with JavaScript Testing using Jest
How-ToWeb Development

Getting Started with JavaScript Testing using Jest

via Dev.to JavaScriptKenta Takeuchi13h ago

This article was originally published on bmf-tech.com . Overview Let's write JavaScript tests using Jest. Preparation Since we want to use jest and ESModules, we need to install babel-preset-2015. (babel-jest is provided with jest.) npm install --save-dev jest babel-preset-2015 The contents of .babelrc look like this. { "presets" : [ "es2015" ] } The package.json looks like this. { "scripts" : { "test" : "jest" }, "devDependencies" : { "babel-preset-es2015" : "^6.24.1" , "jest" : "^23.6.0" } } The directory structure looks like this. tree -a -I "node_modules" . ├── .babelrc ├── package-lock.json ├── package.json ├── src │ ├── esmodules │ │ └── calc.js │ └── native │ └── calc.js └── test ├── esmodules │ └── calc.test.js └── native └── calc.test.js 6 directories, 7 files There are two patterns for creating test files. Files located under a directory named __tests__ are treated as test files. Files with the extensions *.spec.js or *.test.js are treated as test files. This time, we will us

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
2 views

Related Articles

Eighty Years Later, the Chemex Still Makes Better Coffee
How-To

Eighty Years Later, the Chemex Still Makes Better Coffee

Wired • 13h ago

The Day I Realized Coding Is Less About Computers and More About Learning How Humans Think
How-To

The Day I Realized Coding Is Less About Computers and More About Learning How Humans Think

Medium Programming • 13h ago

The Strange Advice Engineers Eventually Hear
How-To

The Strange Advice Engineers Eventually Hear

Medium Programming • 17h ago

How-To

A Gentle Introduction to Mercury

Lobsters • 18h ago

Code Is Culture: Why the Language We Build With Matters
How-To

Code Is Culture: Why the Language We Build With Matters

Medium Programming • 1d ago

Discover More Articles