Skip to content

Commit d005501

Browse files
nzaytseveamodio
authored andcommitted
Adds new unit test structure
- Stored in __tests__ subdirectories - Adds sample tests for iterable and color - Adds restriction for using .only tests suites
1 parent 7f6d914 commit d005501

19 files changed

+430
-256
lines changed

.vscode-test.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { defineConfig } = require('@vscode/test-cli');
2+
3+
module.exports = defineConfig([
4+
{
5+
mocha: {
6+
ui: 'bdd',
7+
timeout: 20000,
8+
},
9+
label: 'unitTests',
10+
files: 'out/**/*.test.js',
11+
},
12+
]);

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- Adds vscode-test to run unit-tests — closes [#3570](https://github.com/gitkraken/vscode-gitlens/issues/3570)
12+
913
### Fixed
1014

1115
- Fixes [#3592](https://github.com/gitkraken/vscode-gitlens/issues/3592) - Connecting to an integration via Remotes view (but likely others) doesn't work

ThirdPartyNotices.txt

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ GitLens
33
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
44
This project incorporates components from the projects listed below.
55

6-
1. @lit/context version 1.1.2 (https://github.com/lit/lit)
7-
2. @lit/react version 1.0.5 (https://github.com/lit/lit)
8-
3. @lit/task version 1.0.1 (https://github.com/lit/lit)
9-
4. @microsoft/fast-element version 1.13.0 (https://github.com/Microsoft/fast)
10-
5. @microsoft/fast-foundation version 2.49.6 (https://github.com/Microsoft/fast)
11-
6. @microsoft/fast-react-wrapper version 0.3.24 (https://github.com/Microsoft/fast)
12-
7. @octokit/graphql version 8.1.1 (https://github.com/octokit/graphql.js)
13-
8. @octokit/request-error version 6.1.4 (https://github.com/octokit/request-error.js)
14-
9. @octokit/request version 9.1.3 (https://github.com/octokit/request.js)
15-
10. @octokit/types version 13.5.0 (https://github.com/octokit/types.ts)
16-
11. @opentelemetry/api version 1.9.0 (https://github.com/open-telemetry/opentelemetry-js)
17-
12. @opentelemetry/exporter-trace-otlp-http version 0.53.0 (https://github.com/open-telemetry/opentelemetry-js)
18-
13. @opentelemetry/resources version 1.26.0 (https://github.com/open-telemetry/opentelemetry-js)
19-
14. @opentelemetry/sdk-trace-base version 1.26.0 (https://github.com/open-telemetry/opentelemetry-js)
20-
15. @opentelemetry/semantic-conventions version 1.27.0 (https://github.com/open-telemetry/opentelemetry-js)
21-
16. @shoelace-style/shoelace version 2.16.0 (https://github.com/shoelace-style/shoelace)
22-
17. @vscode/codicons version 0.0.36 (https://github.com/microsoft/vscode-codicons)
23-
18. @vscode/webview-ui-toolkit version 1.4.0 (https://github.com/microsoft/vscode-webview-ui-toolkit)
24-
19. ansi-regex version 6.1.0 (https://github.com/chalk/ansi-regex)
25-
20. billboard.js version 3.13.0 (https://github.com/naver/billboard.js)
26-
21. fast-string-truncated-width version 1.1.0 (https://github.com/fabiospampinato/fast-string-truncated-width)
6+
1. @gk-nzaytsev/fast-string-truncated-width version 1.1.0 (https://github.com/nzaytsev/fast-string-truncated-width)
7+
2. @lit/context version 1.1.2 (https://github.com/lit/lit)
8+
3. @lit/react version 1.0.5 (https://github.com/lit/lit)
9+
4. @lit/task version 1.0.1 (https://github.com/lit/lit)
10+
5. @microsoft/fast-element version 1.13.0 (https://github.com/Microsoft/fast)
11+
6. @microsoft/fast-foundation version 2.49.6 (https://github.com/Microsoft/fast)
12+
7. @microsoft/fast-react-wrapper version 0.3.24 (https://github.com/Microsoft/fast)
13+
8. @octokit/graphql version 8.1.1 (https://github.com/octokit/graphql.js)
14+
9. @octokit/request-error version 6.1.4 (https://github.com/octokit/request-error.js)
15+
10. @octokit/request version 9.1.3 (https://github.com/octokit/request.js)
16+
11. @octokit/types version 13.5.0 (https://github.com/octokit/types.ts)
17+
12. @opentelemetry/api version 1.9.0 (https://github.com/open-telemetry/opentelemetry-js)
18+
13. @opentelemetry/exporter-trace-otlp-http version 0.53.0 (https://github.com/open-telemetry/opentelemetry-js)
19+
14. @opentelemetry/resources version 1.26.0 (https://github.com/open-telemetry/opentelemetry-js)
20+
15. @opentelemetry/sdk-trace-base version 1.26.0 (https://github.com/open-telemetry/opentelemetry-js)
21+
16. @opentelemetry/semantic-conventions version 1.27.0 (https://github.com/open-telemetry/opentelemetry-js)
22+
17. @shoelace-style/shoelace version 2.16.0 (https://github.com/shoelace-style/shoelace)
23+
18. @vscode/codicons version 0.0.36 (https://github.com/microsoft/vscode-codicons)
24+
19. @vscode/webview-ui-toolkit version 1.4.0 (https://github.com/microsoft/vscode-webview-ui-toolkit)
25+
20. ansi-regex version 6.1.0 (https://github.com/chalk/ansi-regex)
26+
21. billboard.js version 3.13.0 (https://github.com/naver/billboard.js)
2727
22. https-proxy-agent version 5.0.1 (https://github.com/TooTallNate/node-https-proxy-agent)
2828
23. iconv-lite version 0.6.3 (https://github.com/ashtuchkin/iconv-lite)
2929
24. lit version 3.2.0 (https://github.com/lit/lit)
@@ -39,6 +39,33 @@ This project incorporates components from the projects listed below.
3939
34. sortablejs version 1.15.0 (https://github.com/SortableJS/Sortable)
4040
35. tslib version 2.7.0 (https://github.com/Microsoft/tslib)
4141

42+
%% @gk-nzaytsev/fast-string-truncated-width NOTICES AND INFORMATION BEGIN HERE
43+
=========================================
44+
The MIT License (MIT)
45+
46+
Copyright (c) 2024-present Fabio Spampinato
47+
48+
Permission is hereby granted, free of charge, to any person obtaining a
49+
copy of this software and associated documentation files (the "Software"),
50+
to deal in the Software without restriction, including without limitation
51+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
52+
and/or sell copies of the Software, and to permit persons to whom the
53+
Software is furnished to do so, subject to the following conditions:
54+
55+
The above copyright notice and this permission notice shall be included in
56+
all copies or substantial portions of the Software.
57+
58+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
63+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
64+
DEALINGS IN THE SOFTWARE.
65+
66+
=========================================
67+
END OF @gk-nzaytsev/fast-string-truncated-width NOTICES AND INFORMATION
68+
4269
%% @lit/context NOTICES AND INFORMATION BEGIN HERE
4370
=========================================
4471
BSD 3-Clause License
@@ -1917,33 +1944,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19171944
=========================================
19181945
END OF billboard.js NOTICES AND INFORMATION
19191946

1920-
%% fast-string-truncated-width NOTICES AND INFORMATION BEGIN HERE
1921-
=========================================
1922-
The MIT License (MIT)
1923-
1924-
Copyright (c) 2024-present Fabio Spampinato
1925-
1926-
Permission is hereby granted, free of charge, to any person obtaining a
1927-
copy of this software and associated documentation files (the "Software"),
1928-
to deal in the Software without restriction, including without limitation
1929-
the rights to use, copy, modify, merge, publish, distribute, sublicense,
1930-
and/or sell copies of the Software, and to permit persons to whom the
1931-
Software is furnished to do so, subject to the following conditions:
1932-
1933-
The above copyright notice and this permission notice shall be included in
1934-
all copies or substantial portions of the Software.
1935-
1936-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1937-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1938-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1939-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1940-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1941-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1942-
DEALINGS IN THE SOFTWARE.
1943-
1944-
=========================================
1945-
END OF fast-string-truncated-width NOTICES AND INFORMATION
1946-
19471947
%% https-proxy-agent NOTICES AND INFORMATION BEGIN HERE
19481948
=========================================
19491949
https-proxy-agent

eslint.config.mjs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,24 @@ export default ts.config(
440440
'@typescript-eslint/no-restricted-imports': 'off',
441441
},
442442
},
443-
// {
444-
// name: 'tests:unit',
445-
// files: ['src/test/**/*'],
446-
// rules: {
447-
// 'no-restricted-imports': 'off',
448-
// '@typescript-eslint/no-unused-vars': 'off',
449-
// },
450-
// },
443+
{
444+
name: 'tests:unit',
445+
files: ['**/__tests__/**', 'src/test/suite/**'],
446+
rules: {
447+
'no-restricted-imports': 'off',
448+
'@typescript-eslint/no-restricted-imports': 'off',
449+
'@typescript-eslint/no-unused-vars': 'off',
450+
'no-restricted-syntax': [
451+
'error',
452+
{
453+
message: "Don't forget to remove .only from test suites",
454+
selector: 'CallExpression MemberExpression[object.name="suite"][property.name="only"]',
455+
},
456+
{
457+
message: "Don't forget to remove .only from tests",
458+
selector: 'CallExpression MemberExpression[object.name="test"][property.name="only"]',
459+
},
460+
],
461+
},
462+
},
451463
);

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17948,6 +17948,7 @@
1794817948
"icons:apply": "node ./scripts/applyIconsContribution.mjs",
1794917949
"icons:svgo": "svgo -q -f ./images/icons/ --config svgo.config.js",
1795017950
"lint": "pnpm run lint:clear-cache && eslint .",
17951+
"lint:fix": "pnpm run lint:clear-cache && eslint . --fix",
1795117952
"lint:webviews": "pnpm run lint:clear-cache && eslint \"src/webviews/apps/**/*.ts?(x)\"",
1795217953
"lint:clear-cache": "npx rimraf .eslintcache",
1795317954
"package": "vsce package --no-dependencies",
@@ -17960,7 +17961,7 @@
1796017961
"pub-pre": "vsce publish --no-dependencies --pre-release",
1796117962
"rebuild": "pnpm run reset && pnpm run build",
1796217963
"reset": "pnpm run clean && pnpm install --frozen-lockfile",
17963-
"test": "node ./out/test/runTest.js",
17964+
"test": "vscode-test",
1796417965
"test:e2e": "playwright test -c tests/e2e/playwright.config.ts",
1796517966
"watch": "webpack --watch --mode development",
1796617967
"watch:extension": "webpack --watch --mode development --config-name extension",
@@ -17973,13 +17974,14 @@
1797317974
"update-dts:main": "pushd \"src/@types\" && npx @vscode/dts main && popd",
1797417975
"update-emoji": "node ./scripts/generateEmojiShortcodeMap.mjs",
1797517976
"update-licenses": "node ./scripts/generateLicenses.mjs",
17976-
"-pretest": "pnpm run build:tests",
17977+
"pretest": "pnpm run build:tests",
1797717978
"vscode:prepublish": "pnpm run bundle"
1797817979
},
1797917980
"dependencies": {
1798017981
"@gitkraken/gitkraken-components": "10.6.0",
1798117982
"@gitkraken/provider-apis": "0.24.2",
1798217983
"@gitkraken/shared-web-components": "0.1.1-rc.15",
17984+
"@gk-nzaytsev/fast-string-truncated-width": "1.1.0",
1798317985
"@lit/context": "1.1.2",
1798417986
"@lit/react": "1.0.5",
1798517987
"@lit/task": "1.0.1",
@@ -17988,8 +17990,8 @@
1798817990
"@microsoft/fast-react-wrapper": "0.3.24",
1798917991
"@octokit/graphql": "8.1.1",
1799017992
"@octokit/request": "9.1.3",
17991-
"@octokit/types": "13.5.0",
1799217993
"@octokit/request-error": "6.1.4",
17994+
"@octokit/types": "13.5.0",
1799317995
"@opentelemetry/api": "1.9.0",
1799417996
"@opentelemetry/exporter-trace-otlp-http": "0.53.0",
1799517997
"@opentelemetry/resources": "1.26.0",
@@ -18000,7 +18002,6 @@
1800018002
"@vscode/webview-ui-toolkit": "1.4.0",
1800118003
"ansi-regex": "6.1.0",
1800218004
"billboard.js": "3.13.0",
18003-
"fast-string-truncated-width": "1.1.0",
1800418005
"https-proxy-agent": "5.0.1",
1800518006
"iconv-lite": "0.6.3",
1800618007
"lit": "3.2.0",
@@ -18027,6 +18028,7 @@
1802718028
"@types/sortablejs": "1.15.8",
1802818029
"@types/vscode": "1.82.0",
1802918030
"@typescript-eslint/parser": "8.5.0",
18031+
"@vscode/test-cli": "^0.0.10",
1803018032
"@vscode/test-electron": "2.4.1",
1803118033
"@vscode/test-web": "0.0.60",
1803218034
"@vscode/vsce": "3.1.0",

0 commit comments

Comments
 (0)