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

add docs for running tests with VS Code #168

Closed
Albert-Gao opened this issue Jul 20, 2019 · 2 comments
Closed

add docs for running tests with VS Code #168

Albert-Gao opened this issue Jul 20, 2019 · 2 comments
Labels
scope: docs Documentation could be improved. Or changes that only affect docs scope: integration Related to an integration, not necessarily to core (but could influence core) solution: duplicate This issue or pull request already exists

Comments

@Albert-Gao
Copy link

Thanks for this awesome tool.
Everything works well except for debugging the test in VSC

I have to manually add ts-jest config in package.json when using vsc jest plugin, and manually remove it when using tsdx test

What am I missing?

@Albert-Gao Albert-Gao changed the title add description for debug in VSC add description for debugging in VSC Jul 20, 2019
@pstrh
Copy link

pstrh commented Sep 20, 2019

I have the same issue in VSC and a similar problem with Intellij. Intellij requires a jest config to start/debug tests directly from within the IDE. The jest config is not present in the created project as it is only created on the fly by tsdx if tsdx test is called.

@Albert-Gao tsdx test not only creates a jest config on the fly but it also merges the created config with the jest section in the package.json. Probably the result of this merge is not a valid configuration.

If I copy the jest config that tsdx creates into the package.json, tsdx test as well as running/debugging tests in VSC and Intellij works for me.

"jest": {
      "transform": {
        ".(ts|tsx)": "ts-jest"
      },
      "transformIgnorePatterns": ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"],
      "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
      "collectCoverageFrom": ["src/**/*.{ts,tsx}"],
      "testMatch": ["<rootDir>/**/*.(spec|test).{ts,tsx}"],
      "testURL": "http://localhost",
      "rootDir": ".",
      "watchPlugins": [
        "jest-watch-typeahead/filename",
        "jest-watch-typeahead/testname"
      ]
  }

@jaredpalmer This seems like a general design problem if development tools need the jest configuration (that is not present as it's generated on the fly). Off the top of my head I don't have a good solution for this problem. Generating the jest config into the package.json would be the first idea. But with the downside that the package.json would eventually require manually adaption if the jest configuration for tsdx changes.

@agilgur5
Copy link
Collaborator

This issue more documentation-focused, but otherwise same issue as in #270 . Per that issue, solution is to generate a jest.config.js file with tsdx test --write-file (similar to tsdx lint --write-file, where IDE integrations are very common), and ideally make it a one-liner with a TSDX Jest preset.

I'm not sure if TSDX should generate jest.config.js by default (as not everyone uses an IDE integration), so should at least add docs if it won't be.

@agilgur5 agilgur5 added scope: docs Documentation could be improved. Or changes that only affect docs solution: duplicate This issue or pull request already exists labels Mar 9, 2020
@agilgur5 agilgur5 changed the title add description for debugging in VSC add docs for running tests with VS Code Mar 9, 2020
@agilgur5 agilgur5 closed this as completed Mar 9, 2020
@agilgur5 agilgur5 added the scope: integration Related to an integration, not necessarily to core (but could influence core) label Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: docs Documentation could be improved. Or changes that only affect docs scope: integration Related to an integration, not necessarily to core (but could influence core) solution: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants