mtiller / ts-jest-sample Goto Github PK
View Code? Open in Web Editor NEWA sample repo leveraging TypeScript, jest and ts-jest (with code coverage and debugging)
A sample repo leveraging TypeScript, jest and ts-jest (with code coverage and debugging)
Thanks for pulling this together. It helped me set this up to work.
The only thing that I couldn't get to work was the launch setting, but I found an official snippet instead that DID work:
https://github.com/Microsoft/vscode-recipes/tree/master/debugging-jest-tests
Hi,
So i had two issue initially when i ran your example. One was addressed here #1 with the fix of adding a different configuration in launch.
Afterwards, I wrote some extra code and tried to step into it. However, whenever i stepped into the method it would not line up or it would be off by a line. I'm guessing there is some is something i'm missing about the source mapping.
https://github.com/darewreck54/ts-jest-sample
if you run this repo, and put a break point at line 29 sound-consumer.spec.ts and step into it, you'll notice that you are off by a line. It will jump to the file, but be one line offset of where it should be.
Also if you update the version of
"devDependencies": {
"@types/jest": "^23.0.0",
"jest": "^23.1.0",
"typescript": "^2.9.1"
},
"scripts": {
"compile": "tsc",
"test": "jest"
},
"dependencies": {
"ts-jest": "^22.4.6"
}
and run it again, you will notice that when you step into the same file, it will be way off; whether its stepping into the contructor of SoundPlayerConsumer or when you step into the method playSoundFile
i'm currently using npm 6.1.0 and node 8.11.2
Any idea how to fix the source mapping issue?
Thanks,
Derek
Your project runs fine. But I am getting a lot of errors that describe, it, and expect cannot be found in my test. Where are these coming from?
My test looks like:
describe('A suite', function() {
it('should render without throwing an error', function() {
expect(shallow(<CancelButton />).contains(<button className="btn btn-default"></button>)).toBe(true);
});
it('should be selectable by class "foo"', function() {
expect(shallow(<CancelButton />).contains(<button className="btn btn-default"></button>)).toBe(true);
expect(shallow(<CancelButton />).is('.btn')).toBe(true);
});
it('should mount in a full DOM', function() {
expect(mount(<CancelButton />).find('.btn').length).toBe(1);
});
});
Hello, when I clone and do Yarn install, it just times out when running debugger.
Am on Mac with latest code and Node 11.
This compiles __tests__
into lib
as well.
I'd like to only compile src
.
But as soon as I add "include": ["src"]
to tsconfig.json
, It stops applying that config to the tests VS Code.
What to do?
npm 5.6.0 node 8.10.0 on windows same issue on linux node 10.9.0 npm 6.4.1
just cloned it did a npm i then npm test and crash:
which is annoying be cause i cloned your project because of the same error
FAIL tests\base.spec.ts
● Test suite failed to run
SecurityError: localStorage is not available for opaque origins
at Window.get localStorage [as localStorage] (node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
at Array.forEach (<anonymous>)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | Unknown | Unknown | Unknown | Unknown | |
---------- | ---------- | ---------- | ---------- | ---------- | ------------------- |
Test Suites: 1 failed, 1 total | |||||
Tests: 0 total | |||||
Snapshots: 0 total | |||||
Time: 1.495s | |||||
Ran all test suites. | |||||
npm ERR! Test failed. See above for more details. |
I've tried snyk to test my repo's and fond some
What you think about them?
Tested 110 dependencies for known vulnerabilities, found 6 vulnerabilities, 23 vulnerable paths.
? ✗ 14 Low vulnerabilities introduced in hoek
Info: https://snyk.io/package/npm/hoek/2.16.3
? ✗ Medium severity vuln found in [email protected], introduced via [email protected]
Description: Uninitialized Memory Exposure
Info: https://snyk.io/vuln/npm:stringstream:20180511
From: [email protected] > [email protected] > [email protected]
? ✗ Medium severity vuln found in [email protected], introduced via [email protected]
Description: Insecure Randomness
Info: https://snyk.io/vuln/npm:cryptiles:20180710
? ✗ Medium severity vuln found in [email protected], introduced via [email protected]
Description: Insecure Randomness
Info: https://snyk.io/vuln/npm:cryptiles:20180710
From: [email protected] > [email protected]
? ✗ Medium severity vuln found in [email protected], introduced via [email protected]
Description: Insecure Randomness
Info: https://snyk.io/vuln/npm:cryptiles:20180710
From: [email protected] > [email protected] > [email protected]
? ✗ Medium severity vuln found in [email protected], introduced via [email protected]
Description: Insecure Randomness
Info: https://snyk.io/vuln/npm:cryptiles:20180710
From: [email protected] > [email protected] > [email protected] > [email protected]
Seem's that we can try to fix with upgrading?
I've cloned this - and can't get it work on my workspace.
Node version 8.11.2
I clone, npm i
and npm test
and I get:
> [email protected] test /home/davidj/git-workspace/ts-jest-sample
> jest --verbose
● Deprecation Warning:
Option "mapCoverage" has been removed, as it's no longer necessary.
Please update your configuration.
Configuration Documentation:
https://facebook.github.io/jest/docs/configuration.html
ie. no test output
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.