From 690905b78b723c8ad884855d1c26dfe05e210966 Mon Sep 17 00:00:00 2001 From: bogdannechyporenko Date: Tue, 31 Jan 2023 12:50:46 +0100 Subject: [PATCH 1/5] Described how to configure jest tests in IntelliJ Signed-off-by: bogdannechyporenko --- docs/local-dev/cli-build-system.md | 13 +++++++++++++ docs/plugins/testing.md | 12 +----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/local-dev/cli-build-system.md b/docs/local-dev/cli-build-system.md index cc364d0ca5..ba65bedb9f 100644 --- a/docs/local-dev/cli-build-system.md +++ b/docs/local-dev/cli-build-system.md @@ -595,6 +595,19 @@ If you also want to enable source maps when debugging tests, you can do so by se } ``` +### Debugging Jest Tests + +To configure the debugging of your tests in IntelliJ, you have to: + +1. Update Jest configuration template by: + +- Click on "Edit Configurations" on top panel +- In the modal dialog click on link "Edit configuration templates..." located in the bottom left corner. +- In "Jest package" you have to point to relative path of jest module (it will be suggested by IntelliJ), i.e. ~/proj/backstage/node_modules/jest +- In "Jest config" point to your jest configuration file, use absolute path for that, i.e. `--config /Users/user/proj/backstage/packages/cli/config/jest.js --runInBand` + +2. Now you can run any tests by clicking on green arrow located on `describe` or `it`. + ## Publishing Package publishing is an optional part of the Backstage build system and not diff --git a/docs/plugins/testing.md b/docs/plugins/testing.md index baee47c695..2fa086c444 100644 --- a/docs/plugins/testing.md +++ b/docs/plugins/testing.md @@ -371,14 +371,4 @@ Note: wrapping in the test application **requires** you to do a `find()` or # Debugging Jest Tests -Currently, debugging Jest tests using IntelliJ or `node-debugger` is possible -but can be -[problematic to set up.](https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000634564-Debugging-Jest-unit-tests) - -It is possible, but you might spend a decent amount of time configuring your -IDE. - -In most cases, we have found that using `console.log` works well. - -Note: if your console.logs are not being displayed, focus your specific unit -test from the command line by running them like so `yarn test MyTest`. +You can find it [here](https://backstage.io/docs/local-dev/cli-build-system#debugging-jest-tests) From 006f84dc86d8cb18d8cef8b6600a41711724807a Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 13 Feb 2023 14:50:03 +0100 Subject: [PATCH 2/5] Updated the 'Debugging Jest Tests' section Signed-off-by: bnechyporenko --- docs/local-dev/cli-build-system.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/local-dev/cli-build-system.md b/docs/local-dev/cli-build-system.md index ba65bedb9f..bef0ef9d97 100644 --- a/docs/local-dev/cli-build-system.md +++ b/docs/local-dev/cli-build-system.md @@ -597,7 +597,11 @@ If you also want to enable source maps when debugging tests, you can do so by se ### Debugging Jest Tests -To configure the debugging of your tests in IntelliJ, you have to: +For your productivity working with unit tests it's quite essential to have your debugging configured in IDE. It will help you to identify the root cause of the issue faster. + +Each of IDE has own way to set it up. We started with giving an example how to configure it in Intellij IDEA. In a near future we might also add the information for VS Code. + +#### Intellij IDEA 1. Update Jest configuration template by: From a8c0c0383e013a8a50b84678eab28baa475a87a6 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Mon, 13 Feb 2023 15:28:27 +0100 Subject: [PATCH 3/5] Updated the 'Debugging Jest Tests' section Signed-off-by: bnechyporenko --- docs/local-dev/cli-build-system.md | 39 +++++++++++++----------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/docs/local-dev/cli-build-system.md b/docs/local-dev/cli-build-system.md index bef0ef9d97..ec0f3273fb 100644 --- a/docs/local-dev/cli-build-system.md +++ b/docs/local-dev/cli-build-system.md @@ -556,7 +556,22 @@ The overrides in a single `package.json` may for example look like this: }, ``` -If you want to configure editor integration for tests we recommend executing the bundled configuration directly with Jest rather than running through the Yarn test script. For example, with the Jest extension for VS Code the configuration would look something like this: +### Debugging Jest Tests + +For your productivity working with unit tests it's quite essential to have your debugging configured in IDE. It will help you to identify the root cause of the issue faster. + +#### Intellij IDEA + +1. Update Jest configuration template by: + +- Click on "Edit Configurations" on top panel +- In the modal dialog click on link "Edit configuration templates..." located in the bottom left corner. +- In "Jest package" you have to point to relative path of jest module (it will be suggested by IntelliJ), i.e. ~/proj/backstage/node_modules/jest +- In "Jest config" point to your jest configuration file, use absolute path for that, i.e. `--config /Users/user/proj/backstage/packages/cli/config/jest.js --runInBand` + +2. Now you can run any tests by clicking on green arrow located on `describe` or `it`. + +#### VS Code ```jsonc { @@ -571,7 +586,7 @@ If you want to configure editor integration for tests we recommend executing the } ``` -If you also want to enable source maps when debugging tests, you can do so by setting the `ENABLE_SOURCE_MAPS` environment variable. For example, a complete launch configuration for VS Code debugging may look like this: +A complete launch configuration for VS Code debugging may look like this: ```json { @@ -583,9 +598,6 @@ If you also want to enable source maps when debugging tests, you can do so by se "disableOptimisticBPs": true, "program": "${workspaceFolder}/node_modules/.bin/jest", "cwd": "${workspaceFolder}", - "env": { - "ENABLE_SOURCE_MAPS": "true" - }, "args": [ "--config", "node_modules/@backstage/cli/config/jest.js", @@ -595,23 +607,6 @@ If you also want to enable source maps when debugging tests, you can do so by se } ``` -### Debugging Jest Tests - -For your productivity working with unit tests it's quite essential to have your debugging configured in IDE. It will help you to identify the root cause of the issue faster. - -Each of IDE has own way to set it up. We started with giving an example how to configure it in Intellij IDEA. In a near future we might also add the information for VS Code. - -#### Intellij IDEA - -1. Update Jest configuration template by: - -- Click on "Edit Configurations" on top panel -- In the modal dialog click on link "Edit configuration templates..." located in the bottom left corner. -- In "Jest package" you have to point to relative path of jest module (it will be suggested by IntelliJ), i.e. ~/proj/backstage/node_modules/jest -- In "Jest config" point to your jest configuration file, use absolute path for that, i.e. `--config /Users/user/proj/backstage/packages/cli/config/jest.js --runInBand` - -2. Now you can run any tests by clicking on green arrow located on `describe` or `it`. - ## Publishing Package publishing is an optional part of the Backstage build system and not From 79c6b9aa0e1982da010c1bdd2c2969c395ac76fc Mon Sep 17 00:00:00 2001 From: bogdannechyporenko Date: Mon, 13 Feb 2023 19:18:20 +0100 Subject: [PATCH 4/5] Added Intellij to a Vale vocabulary Signed-off-by: bogdannechyporenko --- .github/vale/Vocab/Backstage/accept.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/vale/Vocab/Backstage/accept.txt b/.github/vale/Vocab/Backstage/accept.txt index e6380a17f0..a488ad8f87 100644 --- a/.github/vale/Vocab/Backstage/accept.txt +++ b/.github/vale/Vocab/Backstage/accept.txt @@ -160,6 +160,7 @@ indexable inlined inlinehilite integrator's +Intellij interop JaCoCo JavaScript From b16a9c59f5de06b27854c79abcd713c3d5cb7183 Mon Sep 17 00:00:00 2001 From: bnechyporenko Date: Tue, 14 Feb 2023 08:40:29 +0100 Subject: [PATCH 5/5] Renamed Intellij to IntelliJ Signed-off-by: bnechyporenko --- .github/vale/Vocab/Backstage/accept.txt | 1 - docs/local-dev/cli-build-system.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/vale/Vocab/Backstage/accept.txt b/.github/vale/Vocab/Backstage/accept.txt index a488ad8f87..e6380a17f0 100644 --- a/.github/vale/Vocab/Backstage/accept.txt +++ b/.github/vale/Vocab/Backstage/accept.txt @@ -160,7 +160,6 @@ indexable inlined inlinehilite integrator's -Intellij interop JaCoCo JavaScript diff --git a/docs/local-dev/cli-build-system.md b/docs/local-dev/cli-build-system.md index ec0f3273fb..424b5f2c0c 100644 --- a/docs/local-dev/cli-build-system.md +++ b/docs/local-dev/cli-build-system.md @@ -560,7 +560,7 @@ The overrides in a single `package.json` may for example look like this: For your productivity working with unit tests it's quite essential to have your debugging configured in IDE. It will help you to identify the root cause of the issue faster. -#### Intellij IDEA +#### IntelliJ IDEA 1. Update Jest configuration template by: