Skip to content

Commit

Permalink
feat: integrate ts-expect
Browse files Browse the repository at this point in the history
  • Loading branch information
kengoldfarb committed Apr 24, 2020
1 parent e37cdf8 commit 2d8da7d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export { default as faker } from './src/faker'
export * from './src/faker'
export default BaseTest
export { default as test } from './src/decorators'
export { TypeOf, TypeEqual } from 'ts-expect'
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"chai": "^4.2.0",
"faker": "^4.1.0",
"jest": "^25.4.0",
"ts-expect": "^1.1.0",
"ts-jest": "^25.4.0"
},
"babel": {
Expand All @@ -74,4 +75,4 @@
"<rootDir>/node_modules/"
]
}
}
}
21 changes: 21 additions & 0 deletions src/assert.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import BaseTest from './BaseTest'
import test from './decorators'
import assert from './assert'

interface ICustomObj {
testStr: string
}

export default class AssertTest extends BaseTest {
@test('can assert types')
protected static async doesCallBeforeAll() {
assert.expectType<string>('string')
assert.expectType<number>(123)

const myCustomObj: ICustomObj = {
testStr: 'blah'
}

assert.expectType<ICustomObj>(myCustomObj)
}
}
9 changes: 6 additions & 3 deletions src/assert.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { assert } from 'chai'

export interface ISpruceAssert extends Chai.AssertStatic {}
import { expectType } from 'ts-expect'

// TODO: We could extend assert here
/**
* 馃尣馃 Assert things in tests
*
* Extends the chai assert library: https://www.chaijs.com/api/assert/
* */
const spruceAssert: ISpruceAssert = assert
const spruceAssert = {
...assert,
expectType
}

export default spruceAssert
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8173,6 +8173,11 @@ trim-off-newlines@^1.0.0:
resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3"
integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM=

ts-expect@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ts-expect/-/ts-expect-1.1.0.tgz#52a280a149e1943ff7473d3dcb2fe17f85f63853"
integrity sha512-cKoBZ47X85x/Qh7taf30m3BhOJOhtNbb7KFHz9CCuWeRSAh0wzprnmiN9TSOQ0FWp3+qDWS5f2FDnxkY93Kdfw==

ts-jest@^25.4.0:
version "25.4.0"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-25.4.0.tgz#5ad504299f8541d463a52e93e5e9d76876be0ba4"
Expand Down

0 comments on commit 2d8da7d

Please sign in to comment.