-
Notifications
You must be signed in to change notification settings - Fork 407
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
Testing Support for LWC: Support internal workspace #2094
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
98c08ad
lwc test: basic support for internal dev workspace
6d86aa7
add workspace type name for telemetry
2cac16e
Update lightning-lsp-common reference
9bfc054
Fix tests for test runner executable
f645dd2
cli args and test runner executable tests
59dba5a
refactor workspace type services and add tests
9e0d7a2
tests for sending workspace type telemetry
e7cd96e
fix stub types
89ccec2
send exception for unsupported workspace
ee65a02
update package.json
8ad810e
Merge branch 'develop' into xyc/lwc-test-core
xyc fd1542d
remove workspaceContains:modules activation event
46c64ee
Merge branch 'develop' into xyc/lwc-test-core
xyc 378915e
Merge branch 'develop' into xyc/lwc-test-core
1809a3f
Activate for core partial workspace
7b7317e
setting sfdx:internal_dev context eagerly on lwc test features activa…
bdf12df
Merge branch 'develop' into xyc/lwc-test-core
0196893
add licensing
cec436f
Merge branch 'develop' into xyc/lwc-test-core
3848d2e
Update packages/salesforcedx-vscode-lwc/src/testSupport/index.ts
dcae08f
move getTestWorkspaceFolder to workspace module
64b0b0f
remove url in helper text
4b19484
Merge branch 'develop' into xyc/lwc-test-core
ec9fc88
PR feedback: refactor getCliArgsFromJestArgs
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/salesforcedx-vscode-lwc/src/testSupport/workspace/getCliArgsFromJestArgs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { TestRunType } from '../testRunner/testRunner'; | ||
|
||
/** | ||
* Returns workspace specific jest args from CLI arguments and test run type | ||
* @param jestArgs jest args | ||
* @param testRunType test run type | ||
*/ | ||
export function getCliArgsFromJestArgs( | ||
jestArgs: string[], | ||
testRunType: TestRunType | ||
) { | ||
const cliArgs = ['--', ...jestArgs]; | ||
if (testRunType === TestRunType.DEBUG) { | ||
cliArgs.unshift('--debug'); | ||
} | ||
return cliArgs; | ||
} |
62 changes: 62 additions & 0 deletions
62
packages/salesforcedx-vscode-lwc/src/testSupport/workspace/getLwcTestRunnerExecutable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as vscode from 'vscode'; | ||
import * as which from 'which'; | ||
import { nls } from '../../messages'; | ||
import { telemetryService } from '../../telemetry'; | ||
import { workspaceService } from './workspaceService'; | ||
|
||
/** | ||
* Get the absolute path to LWC Test runner executable, installed in an SFDX project. | ||
* @param cwd path to the workspace folder | ||
* @returns path to LWC Test runner | ||
*/ | ||
export function getLwcTestRunnerExecutable(cwd: string) { | ||
const workspaceType = workspaceService.getCurrentWorkspaceType(); | ||
if (workspaceService.isSFDXWorkspace(workspaceType)) { | ||
const lwcTestRunnerExecutable = path.join( | ||
cwd, | ||
'node_modules', | ||
'.bin', | ||
'lwc-jest' | ||
); | ||
if (fs.existsSync(lwcTestRunnerExecutable)) { | ||
return lwcTestRunnerExecutable; | ||
} else { | ||
const errorMessage = nls.localize('no_lwc_jest_found_text'); | ||
console.error(errorMessage); | ||
vscode.window.showErrorMessage(errorMessage); | ||
telemetryService | ||
.sendException('lwc_test_no_lwc_jest_found', errorMessage) | ||
.catch(); | ||
} | ||
} else if (workspaceService.isCoreWorkspace(workspaceType)) { | ||
const lwcTestRunnerExecutable = which.sync('lwc-test', { | ||
nothrow: true | ||
}); | ||
if (lwcTestRunnerExecutable && fs.existsSync(lwcTestRunnerExecutable)) { | ||
return lwcTestRunnerExecutable; | ||
} else { | ||
const errorMessage = nls.localize('no_lwc_testrunner_found_text'); | ||
console.error(errorMessage); | ||
vscode.window.showErrorMessage(errorMessage); | ||
telemetryService | ||
.sendException('lwc_test_no_lwc_testrunner_found', errorMessage) | ||
.catch(); | ||
} | ||
} else { | ||
// This is not expected since test support should not be activated for other workspace types | ||
telemetryService | ||
.sendException( | ||
'lwc_test_no_lwc_testrunner_found', | ||
'Unsupported workspace' | ||
) | ||
.catch(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures proper activation in partial workspace.