Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kulshekhar/ts-jest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v24.0.1
Choose a base ref
...
head repository: kulshekhar/ts-jest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v24.0.2
Choose a head ref
  • 3 commits
  • 15 files changed
  • 2 contributors

Commits on Mar 30, 2019

  1. Bump @types/jest to 24 and fix the associated typings and tests (#994)

    Bump @types/jest and fix mocked typings
    Fixes #991
    MicahChalmer authored and GeeWee committed Mar 30, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ba578b1 View commit details

Commits on Apr 4, 2019

  1. Copy the full SHA
    7e2fcaa View commit details

Commits on Apr 5, 2019

  1. build(deps-dev): bump js-yaml from 3.13.0 to 3.13.1 (#1058)

    Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.13.0 to 3.13.1.
    - [Release notes](https://github.com/nodeca/js-yaml/releases)
    - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
    - [Commits](nodeca/js-yaml@3.13.0...3.13.1)
    
    Signed-off-by: dependabot[bot] <support@dependabot.com>
    dependabot[bot] authored and ahnpnl committed Apr 5, 2019
    Copy the full SHA
    881c956 View commit details
16 changes: 15 additions & 1 deletion e2e/__cases__/test-helpers/pass.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mocked } from 'ts-jest/utils'
import { foo, bar } from './to-mock'
import { foo, bar, MyClass } from './to-mock'
jest.mock('./to-mock')

test('foo', () => {
@@ -15,3 +15,17 @@ test('bar', () => {
expect(mockedBar.dummy.deep.deeper()).toBeUndefined()
expect(mockedBar.dummy.deep.deeper.mock.calls.length).toBe(1)
})

test("MyClass", () => {
const instance = new MyClass("hi");
const otherInstance = new MyClass("there");
expect(mocked(MyClass).mock.calls.length).toBe(2);

const mockedInstance = mocked(instance, true);
// mocked always returns undefined by default
expect(instance.myStr).toBeUndefined();
expect(mockedInstance.myProperty).toBeUndefined();
expect(instance.somethingClassy()).toBeUndefined();
expect(mockedInstance.somethingClassy.mock.calls.length).toBe(1);
expect(mocked(otherInstance).somethingClassy.mock.calls.length).toBe(0);
});
10 changes: 10 additions & 0 deletions e2e/__cases__/test-helpers/to-mock.ts
Original file line number Diff line number Diff line change
@@ -13,3 +13,13 @@ export namespace bar {
}
}
}

export class MyClass {
constructor(s: string) {
this.myProperty = 3
this.myStr = s
}
somethingClassy() { return this.myStr }
public myProperty: number;
public myStr: string;
}
56 changes: 42 additions & 14 deletions e2e/__templates__/default/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/__templates__/default/package.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"version": "0.0.0-tmpl.0",
"private": true,
"devDependencies": {
"@types/jest": "23.3.9",
"@types/jest": "24.0.6",
"@types/node": "10.12.5",
"jest": "24.1.0",
"typescript": "3.1.6"
Loading