Giter Club home page Giter Club logo

unittest's Introduction

フロントエンドのテスト入門

これは「フロントエンド開発のためのテスト入門」の第3章〜第6章で解説する、トレーニングリポジトリです。対象読者は、初めてフロントエンドのテストに取り組まれる方を想定しており、Jestの基本的な使用方法から解説しています。

  • 第3章 はじめの単体テスト
  • 第4章 モック
  • 第5章 UI コンポーネントテスト
  • 第6章 カバレッジレポートの読み方

第3章 はじめの単体テスト

Jest を使用したテストコードを解説します。はじめてテストに取り組まれる方にとって、最適な内容です。

【サンプルコード】src/03/**/*.test.tsx

$ npm test

第4章 モック

テストを実施するうえで、必要不可欠な「モック」について解説します。Jest は標準でモック機能を備えています。

【サンプルコード】src/04/**/*.test.tsx

$ npm test

第5章 UI コンポーネントテスト

Node.js には DOM API がありませんが、jsdom という DOM API をシュミレートするテスト環境を用意することで、実際のブラウザでテストするのと同じようなテストが「高速に」実施できます。Testing Library は、そのテスト環境において、UIコンポーネントテストをサポートするライブラリです。

【サンプルコード】src/05/**/*.test.tsx

$ npm test

第6章 カバレッジレポートの読み方

単体テスト・結合テストに慣れたら、カバレッジレポートを確認して、不足しているテストを見つけてみましょう。カバレッジレポートを確認することで、テストコードを書くポイントがはっきりします。

【サンプルコード】src/06/**/*.test.tsx

$ npm test

unittest's People

Contributors

takefumi-yoshii avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.