-
Notifications
You must be signed in to change notification settings - Fork 459
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
Handle 'use strict' #71
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { } from 'jest'; | ||
import { } from 'node'; | ||
import runJest from '../__helpers__/runJest'; | ||
|
||
describe('use strict', () => { | ||
|
||
it('should show the error locations for "use strict" violations', () => { | ||
|
||
const result = runJest('../use-strict', ['--no-cache', '-t', 'Invalid Strict']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It runs a test that matches the name specified. Running
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really. My bad - somehow missed it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found out about it today myself :) |
||
|
||
const stderr = result.stderr.toString(); | ||
|
||
expect(result.status).toBe(1); | ||
expect(stderr).toContain('Strict.ts:4:4'); | ||
expect(stderr).toContain('Strict.test.ts:9:5'); | ||
|
||
}); | ||
|
||
it('should work with "use strict"', () => { | ||
|
||
const result = runJest('../use-strict', ['--no-cache', '-t', 'Valid Strict']); | ||
|
||
expect(result.status).toBe(0); | ||
|
||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
export function checkStrictValid() { | ||
var v = 33; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
export function checkStrict() { | ||
v = 33; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
declare var jest, describe, it, expect; | ||
|
||
import { checkStrictValid } from '../Strict-valid'; | ||
|
||
describe('Valid Strict', () => { | ||
|
||
it('should not throw an error', () => { | ||
|
||
checkStrictValid(); | ||
|
||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
declare var jest, describe, it, expect; | ||
|
||
import { checkStrict } from '../Strict'; | ||
|
||
describe('Invalid Strict', () => { | ||
|
||
it('should throw an error on line 9', () => { | ||
|
||
checkStrict(); | ||
|
||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"jest": { | ||
"transform": { | ||
".(ts|tsx)": "../../preprocessor.js" | ||
}, | ||
"testResultsProcessor": "../../coverageprocessor.js", | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES5", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noEmitOnError": false, | ||
"jsx": "react", | ||
"allowJs": true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bad idea. We need that folder in each integration test case, because without it, you'll always test version from root
node_modules
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that right away