-
-
Save HudsonAfonso/f89c9f8a2bb50ae035827729b3603438 to your computer and use it in GitHub Desktop.
TDD with TypeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class HelloWorld { | |
public sayHi(name: string): string { | |
return "Hi, " + name; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "mocha"; | |
import "should"; | |
import { HelloWorld } from "../src/HelloWorld"; | |
describe("HelloWorld", () => { | |
let tested: HelloWorld; | |
beforeEach(() => tested = new HelloWorld()); | |
describe("Say hi", () => { | |
it("should say Hi, somkiat", () => { | |
const result = tested.sayHi("somkiat"); | |
const expected = "Hi, somkiat"; | |
result.should.be.equal(expected); | |
}); | |
it("should say Hi, somkiat2", () => { | |
const result = tested.sayHi("somkiat2"); | |
const expected = "Hi, somkiat2"; | |
result.should.be.equal(expected); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "helloworld", | |
"version": "1.0.0", | |
"description": "TDD with TypeScript", | |
"main": "index.js", | |
"scripts": { | |
"test": "mocha" | |
}, | |
"devDependencies": { | |
"@types/mocha": "2.2.39", | |
"@types/should": "8.1.30", | |
"mocha": "3.2.0", | |
"should": "11.2.0", | |
"typescript": "2.1.6" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "helloworld", | |
"version": "1.0.0", | |
"description": "TDD with TypeScript", | |
"main": "index.js", | |
"scripts": { | |
"build": "tsc", | |
"pretest": "npm run build", | |
"test": "mocha dist/tests" | |
} | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "ES6", | |
"module": "commonjs", | |
"noEmitOnError": true, | |
"noImplicitAny": false, | |
"experimentalDecorators": true, | |
"sourceMap": true, | |
"outDir": "dist" | |
}, | |
"exclude": [ | |
"dist", | |
"node_modules" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment