0.1.5 • Published 4 years ago

@peregrine/test-with-decorators v0.1.5

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Node.js linter & tests Node.js deployment Quality Gate Status license npm node version types

Test with decorators

Experimental library for writing tests with decorators. Uses mocha and chai internally.

Notes

  • Make sure to enable the experimentalDecorators (and preferably emitDecoratorMetadata) flag(s) in your tsconfig.json
  • Run tests with the mocha CLI

Demo

import { suite, test, expect } from "@peregrine/test-with-decorators"
import { camelCaseToText, snakeCaseToText } from "../main/textUtils"

@suite
export class TextUtilsTests {
    @test
    public camelCaseToTextShouldConvertTextCorrectly(): void {
        // Arrange
        const camelCaseText = "thisTextIsWrittenInCamelCase"
        const expectedResult = "This text is written in camel case"

        // Act
        const actualResult = camelCaseToText(camelCaseText)

        // Assert
        expect(actualResult).to.equal(expectedResult)
    }

    @test
    public snakeCaseToTextShouldConvertTextCorrectly(): void {
        // Arrange
        const snakeCaseText = "this_text_is_written_in_snake_case"
        const expectedResult = "This text is written in snake case"

        // Act
        const actualResult = snakeCaseToText(snakeCaseText)

        // Assert
        expect(actualResult).to.equal(expectedResult)
    }
}
0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago