Skip to content

書籍「テスト駆動開発」を TypeScript で読み進めてみたレポジトリです。(読了)

Notifications You must be signed in to change notification settings

msfukui/tdd-by-example-for-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Maintainability Test Coverage

TDD by Example for TypeScript

書籍「テスト駆動開発」を TypeScript で読み進めてみるレポジトリです。

Setup

事前に node.js はセットアップしているものとして。

$ npm init
...
$ npm install --save-dev typescript tslint mocha power-assert espower-typescript @types/node @types/mocha
...

A test sample

test/sample.test.ts

import assert = require("assert");
import { say } from "../src/sample";

describe("#say()", () => {
  it("Say, Hello world.", () => {
    assert("Hello world." === say("world"));
  });
});

src/sample.ts

export function say(message: string): string {
  return "Hello " + message + ".";
}

Test

$ npm test

> tdd-by-example-for-typescript@0.0.1 test /tdd-by-example-for-typescript
> mocha --require espower-typescript/guess test/**/*.ts




  #say()
    √ Say, Hello world.


  1 passing (18ms)

$

A watch mode is:

$ npm run test:watch

> tdd-by-example-for-typescript@0.0.1 test /tdd-by-example-for-typescript
> mocha --watch-extensions ts -w --require espower-typescript/guess test/**/*.ts




  #say()
    √ Say, Hello world.


  1 passing (18ms)

([Ctrl] + C)
$ 

Directory Structure

+ dist/ : コンパイル後のコード(*.js)と source map ファイル(*.js.map) 
|  |
|  + src/
|  |
|  + test/
|
+ src/ : 本体のコード(*.ts)
|
+ test/ : テストコード(*.test.ts)

References

About

書籍「テスト駆動開発」を TypeScript で読み進めてみたレポジトリです。(読了)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published