Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to be compatible with latest @types/jest #15

Closed
wants to merge 2 commits into from

Conversation

dobesv
Copy link

@dobesv dobesv commented Jan 22, 2020

Note that this change is not backward-compatible, this will not work with older versions of @types/jest.

Note that this change is not backward-compatible, this will not work with older versions of @types/jest.
@codecov-io
Copy link

codecov-io commented Jan 22, 2020

Codecov Report

Merging #15 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #15   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          15     15           
  Branches        2      2           
=====================================
  Hits           15     15

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac84e9b...25825e8. Read the comment docs.

types/index.d.ts Outdated Show resolved Hide resolved
Co-Authored-By: Userbit <34487074+Userbit@users.noreply.github.com>
@dobesv
Copy link
Author

dobesv commented Jan 25, 2020

@Userbit cool, thanks!

@mattphillips
Copy link
Owner

Hey @dobesv @Userbit thanks for the PR/review!

I'm not sure this PR should be necessary as the types in @types/jest have been updated to be backwards compatible (see DefinitelyTyped/DefinitelyTyped#41766).

I've just started a new project locally with jest-chain and the latest @types/jest types and it all worked fine.

I'm going to go ahead and close this for now, but please feel free to re-open and let me know if it still isn't working.

@dobesv
Copy link
Author

dobesv commented Jan 29, 2020

That sounds even better.

@ben-tbotlabs
Copy link

ben-tbotlabs commented Jan 29, 2020

I think this needs to be reopened because the current types do not work for the "not" matcher

Using
@types/jest@25.1.0
jest@25.1.0
jest-chain@1.1.4
jest-extended@0.11.5
ts-jest@25.0.0

Results in

TypeScript diagnostics (customize using `[jest-config].globals.ts-jest.diagnostics` option):
src/index.spec.ts:10:5 - error TS2339: Property 'not' does not exist on type 'ChainedMatchers<string>'.

10                  .not.toBeNil()

for the .spec.ts file below

function hello() {
	return 'world';
}

describe( 'hello-world', () => {

	it( 'hello invalid', async () => {
		const v = hello();
		expect( v )
			.not.toBeNil()
			.toHaveLength( 5 );

	} );

	it( 'hello valid', async () => {
		const v = hello();
		expect( v )
			.toBeString()
			.toHaveLength( 5 );
	} );
} );

@dobesv
Copy link
Author

dobesv commented Jan 29, 2020

Oh yeah, they did rearrange things a bit in @jest/types, didn't they. I remember running into that, I had to use a different base type.

@ben-tbotlabs
Copy link

I made a Stackblitz project to reproduce the problem quickly https://stackblitz.com/edit/typescript-c4nmax

Error in Stackblitz:
You will see the error squiggly in index.spec.ts

Locally:
Download from Stackblitz
npm install
npm test

@mattphillips
Copy link
Owner

Just published https://www.npmjs.com/package/jest-chain/v/1.1.5 with @dobesv's fix.

Hope you don't mind @dobesv that I copied the solution from this PR and didn't merge, I didn't fancy dealing with the merge conflicts in package.json/yarn.lock

@dobesv
Copy link
Author

dobesv commented Jan 31, 2020

No problem, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants