I use typescript in my Ionic 2 project . How to debug my typescript files ? I try to without webpack file , But it is not a good solution for that !!Can you help me ?
To debug your application, use the keyword debugger in your code which will set the break point
function myBrokenFunction() {
debugger;
// do other stuff
}
Check here for details
WebStorm / InteliJ Supports Typescript debugging. it is using a chrome extension and allow you to put breakpoints in the IDE.
This blog post also covers it
If visual debugging is more your style you could checkout Batarangle, an Angular2 take on the Batarang browser plugin.
If you are using webpack as the app bundler, instead of rollup , try to create a file on your project's root , webpack.config.js , and write this content:
module.exports = {
devtool: 'source-map'
}
In your typescript config file tsconfig.json, yuo must have the entry :
"sourceMap": true
Related
I want to set up prettier to run in the project without having to install the plugin or having to run prettier smth like this:
"prettier-watch": "onchange \"**/*\" -- prettier --write --ignore-unknown {{changed}}"
in the background. Any ideas?
Additionally- read about an option of setting .vscode/settings.json to
{ "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true }
to automatize the setup for newly onboarded developers but this still requires the plugin
I have some sets of Jest test cases that run Puppeteer browser tests.
I have tried these test runners
Jest (vscode-jest)
Jest Test Explorer (Jest Test Explorer for Visual Studio Code)
Jest Runner (vscode-jest-runner)
To me, I like Jest Test Explorer the most but it always auto-start running test cases.
As you can imagine, a lot of Chrome browser instances get launched when I open a project with VS Code.
I found some configurations but they cannot prevent auto-run test cases.
"testExplorer.onStart": "reset", or set to null
"testExplorer.onReload": "reset", or set to null
FYI, an example UI of Jest Test Explorer
Jest (vscode-jest) is a good runner but I can't stop auto-run with these settings as well.
"jest.runAllTestsFirst": false,
"jest.autoEnable": false,
"jest.showCoverageOnLoad": false
Therefore, right now Jest Runner (vscode-jest-runner) is the only runner that does not auto-start unit tests.
In addition, if you have any other test runners to suggest, please let me know.
Thank you so much.
For orta.vscode-jest extension, I added the configuration below in settings.json. You can open settings.json by doing Command + Shift + P (Ctrl + Shift + P on Windows), typing settings JSON and selecting Preferences: Open Settings (JSON).
"jest.autoRun": {
"onStartup": []
}
Or you can simply add:
"jest.autoRun": {}
If you want to run all tests on startup, add all-tests to the onStartup array:
"jest.autoRun": {
"onStartup": ["all-tests"]
}
I just set this simple option into the VS Code's settings.json:
"jest.autoRun": "false"
I made it work by only setting the setting "jest.autoEnable": false, on my settings.json and restarting VSCode. At least, it is working until now and it hasn't broken yet: Disable starting Jest automatically
To open your settings.json:
Press Ctrl+Shift+P
Then type Preferences: Open Settings (JSON)
At the time of writing (Dec 22) the new way to do this (as per https://github.com/jest-community/vscode-jest/blob/master/README.md#how-to-trigger-the-test-run) is to have the following in the VS Code settings.json. Note I had previously tried the other answers but none worked.
"jest.autoRun": { "watch": false }
Go to vscode setting.json
You can either add
"jest.autoRun": "off"
or
"jest.autoRun": false
both are valid options.
You can checkout the official recommended settings here.
https://github.com/jest-community/vscode-jest/blob/master/README.md#how-to-trigger-the-test-run
"jest.autoEnable": false
is deprecated.
What it worked for me was:
File -> preferences -> settings. Then under the panel user (in workspace is as well but I am not sure if you need to modify it there as well), go to extensions -> jest.
There you will have a section jest: auto run and you will find a link "edit in settings.json" and modify what is there for this
"jest.autoRun": {
"watch": false
}
There's some great updated docs here
Migration rule from settings prior to v4:
if "jest.autoEnabled" = false => manual mode: "jest.autoRun": "off"
if "jest.runAllTestsFirst" = false => "jest.autoRun": {"watch": true }
if no customization of the 2 settings and no "jest.autoRun" found =>
First open the jest extension settings.json in the vs code. In the json script add "jest.autoRun": "off" to disable test autorun. Below, I add other options as well.
Source: Documentation
fully manual
there will be no automatic test run, users will trigger test run by either command or context-menu.
Example: "jest.autoRun": "off"
automatically run tests when test file changed
the extension will trigger test run for the given test file upon save.
Example: "jest.autoRun": {"watch": false, "onSave": "test-file"}
automatically run tests when either test or source file changed:
the extension will trigger test run for the given test or source file upon save.
Example: "jest.autoRun": {"watch": false, "onSave": "test-src-file"}
Visual Studio Code does not recognize unit tests grouped in group(...). But it recognizes unit tests which are not grouped. I mean they are standalone test(...). I want to use group, because I need setUp().
There is Run | Debug link above group. When I click Debug or Run the Debug console shows No tests match regular expression "^LocalRepository$".
The tests are running correctly with flutter test command.
Dart SDK: >=2.1.0 <3.0.0
Flutter channel: master
Edit: I found workaround - I just don't use group callback. But I can't run all tests by clicking Run above group.
Make sure you name you test file ending with _test.dart and you will see the run | debug options
I have a Flutter project with two separate test files, both ending in "..._test.dart".
Using the following two test scenarios, one of the files passes, while the second doesn't load and that test fails.
Using launch.json configuration:
{
"name": "Dart: Run all Tests",
"request": "launch",
"type": "dart",
"program": "./test/"
}
Using the VS Code menu item Debug > Start Debugging (F5), which I suspicion just uses the above launch.json configuration, yields the same result.
However, using the VS Code menu item Debug > Start Without Debugging (Ctrl+F5), or "flutter test" from the command line, both tests pass.
I suspect this is an internal configuration issue with the VS Code Dart/Flutter extension, as opposed to a problem with Dart/Flutter code structure.
Are your tests/groups spread across multiple files? There are some limitations to the integration between the VS Code extension and the test package that you may be hitting.
There was a fix in v2.23 (released a few days before your question) that should have improved this a little (removing those Run/Debug links in some places they wont' work) but if you're already on that version then maybe it didn't cover your case.
If you can post a small repro on GitHub I'd definitely like to see if I can improve this. Thanks!
Ensure the test has a name different from ''
Change
test('', () {
...
});
to
test('xxx', () {
...
});
While editing JavaScript source files in Visaul Studio 2017, the following error keeps occuring:
The JavaScript language service has been disabled for the following project(s): ...
Even if I disable the JavaScript language service entirely, the error keeps occuring. Why is this happening and how do I stop this error message from displaying all the time? Can I disable the JavaScript language service entirely?
The solution to the problem was simply to use a tsconfig.json file, even though there were only JavaScript files in my solution.
I've just used the following tsconfig.json file in the root of the project:
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"sourceMap": true,
"target": "es2015",
"module": "amd",
"allowJs": false,
"allowSyntheticDefaultImports": true
},
"exclude": [
"lib",
"node_modules"
]
}
open 'developer command line tool for visual studio'. run :
devenv.exe /resetuserdata
I have been searching for a way to test Typescript in Visual Studio for 2 days now. It seems that there is an issue in doing this. I have tried using different frameworks i just cannot get this to work in a separate project. Does anyone have any suggestions on how to get this to work in a separate project? Do I need to create a web interface where this can be run?
Thank you.
Most TypeScript unit testing frameworks run on the command line.
To integrate these with Visual Studio, you can use a Task Runner like Gulp.
Once you have your gulpfile.js set up to run the tests, it will be visible in the Visual Studio "Task Runner Explorer" window CTRL + ALT + Backspace.
You can set a task to run whenever you build your solution by right-clicking it in Task Runner Explorer and selecting "Bindings -> After Build".
Example Gulp file for Karma:
/// <binding AfterBuild='test' />
var gulp = require('gulp');
var Server = require('karma').Server;
gulp.task('test', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});