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

Dashed-args #1034

Merged
merged 3 commits into from
Jun 14, 2023
Merged

Dashed-args #1034

merged 3 commits into from
Jun 14, 2023

Conversation

connectdotz
Copy link
Collaborator

@connectdotz connectdotz commented Jun 14, 2023

adding a new setting jest.useDashedArgs to convert all camelcase arguments (default) to dashed arguments. This is mainly to support angular projects that are deprecating camelcase arguments.

The actual conversion is done in jest-editor-support (see jest-community/jest-editor-support#103). We are merely passing through this setting.

resolve #923

@coveralls
Copy link

coveralls commented Jun 14, 2023

Pull Request Test Coverage Report for Build 5262229101

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 97.735%

Totals Coverage Status
Change from base Build 4846257155: -0.02%
Covered Lines: 3407
Relevant Lines: 3430

💛 - Coveralls

@connectdotz
Copy link
Collaborator Author

Changes have been tested. Coverage loss is inaccurate.

@connectdotz connectdotz merged commit 479f4b6 into jest-community:master Jun 14, 2023
@connectdotz connectdotz deleted the dashed-args branch June 14, 2023 02:10
@connectdotz connectdotz mentioned this pull request Jun 14, 2023
@stefanrybacki
Copy link

stefanrybacki commented Jul 29, 2023

With the latest preview build it still fails for list tests and watch all options even when useDashedArgs is set to true. Running tests individually from the test file works kinda (executing all tests regardless, which did not work at all before)

Seeing this in the jest output, when starting VSCode

Error: Unknown arguments: listTests, watchAll

@rafagsiqueira
Copy link

Was this merged? Does not seem to be working.

@connectdotz
Copy link
Collaborator Author

It is merged and released in the pre-release v6.0.0. is that the version you tested?

@rafagsiqueira
Copy link

rafagsiqueira commented Aug 11, 2023

It is. Is there a way to check the jest-editor-support version? Perhaps that one did not get updated?
I see that "jest.enable": false, for example works. And that one was also introduced in v6.0.0, correct?

@connectdotz
Copy link
Collaborator Author

yes if you got jest.enable working, then you are probably running the v6.0.0. Can you paste the command line from the Jest terminal output? There should be something like this:

Jest (angular-jest-tutorial)
yarn run v1.22.19
$ ng test --test-location-in-results --json --use-stderr --output-file /var/folders/vg/yw9mltwd1mj_29xbvhwywc980000gn/T/jest_runner_angular_jest_tutorial_501.json --watch --no-coverage --reporters default --reporters /Users/vsun/.vscode/extensions/orta.vscode-jest-6.0.0/out/reporter.js --colors

it will not change the debug config though, which you can change manually - that was available since we introduced the debug config v2 a while back.

@stefanrybacki use case is puzzling too. Can you also paste the full CLI the extension spawned?

@rafagsiqueira
Copy link

rafagsiqueira commented Aug 11, 2023

First of all, thank you so much for your project. This extension is the only one that is flexible enough to get close to working with angular and a multiroot project. I have almost given up on using jest many times now, because I have had a lot of headaches in the past trying to get it to work. However, with your extension, I can at least run all the tests from the context menu, as well as debug them, which is really amazing. Now back to the questions.

The only output I see from jest console is this, even after enabling jest.debugMode:

Jest (etips-registration)

Error: Unknown arguments: listTests, watchAll


[error] failed to retrieve test file list. TestExplorer might show incomplete test items

If I open the developer console I see this:
spawning process with command=ng test etips-registration --listTests --json --watchAll=false options: Object
Running any test from vscode context menu works, using the debug option works as well, after I modified the debug config:

{
  "configurations": [
    {
      "type": "node",
      "name": "vscode-jest-tests.v2",
      "request": "launch",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "cwd": "${workspaceFolder}",
      "runtimeExecutable": "ng",
      "args": [
        "test",
        "etips-registration",
        "--run-in-band",
        "--watch-all=false",
        "--test-name-pattern",
        "${jest.testNamePattern}",
        "--test-path-pattern",
        "${jest.testFile}"
      ]
    }
  ]
}

@connectdotz
Copy link
Collaborator Author

Thanks for the kind words! 😄

I think I found the root cause in jest-editor-support. Will patch it soon. Thanks for raising this issue. 👍

@connectdotz
Copy link
Collaborator Author

@rafagsiqueira and @stefanrybacki, the fix is in. Please feel free to try v6.0.1 pre-release and let me know if it resolves your issue.

@rafagsiqueira
Copy link

@connectdotz you are amazing! I can confirm it works on v6.0.1 pre-release. Thank you very much!

@mjamin
Copy link

mjamin commented Aug 13, 2023

People should note that it currently only works with the @angular-builders/jest:run builder, not with the new @angular-devkit/build-angular:jest as the latter doesn't seem to pass the additional arguments to jest.

Here is a setup that works using @angular-builders/jest:run, for anyone interested.

@rafagsiqueira
Copy link

@mjamin i opened a feature request with angular dev kit to pass the cli options to jest. What do you mean by a setup that works? Did you manage to configure the extension to work with @angular-devkit/build-angular:jest and the vscode-jest extension?

@mjamin
Copy link

mjamin commented Aug 13, 2023

@rafagsiqueira No, the setup is using @angular-builders/jest. I meant the modified debug config, angular.json and vscode-jest settings.

@stefanrybacki
Copy link

@connectdotz I can confirm running tests now works for too, however debugging still used testNamePattern somewhere. I get the following
image

@connectdotz
Copy link
Collaborator Author

yes, the change did not include debug config, see comment here, specifically:

it will not change the debug config though, which you can change manually - that was available since we introduced the debug config v2 a while back.

But you are right that I should update the release note to make sure people are aware of this.

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.

camelcase args are not supported in angular cli
5 participants