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

Can't run tests under different directory with CLI #17993

Closed
wopian opened this issue Jan 1, 2017 · 5 comments
Closed

Can't run tests under different directory with CLI #17993

wopian opened this issue Jan 1, 2017 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@wopian
Copy link

wopian commented Jan 1, 2017

  • VSCode Version: 1.8.1
  • OS Version: Windows 10

Launching tests within VS Code using the debugger, my tests are run under ./lib/test as defined in the launch.json config file. (Example)

However running tests from CLI, I can't seem to pass the correct tests path.

npm test or node ./node_modules/vscode/bin/test both attempt and fail to run tests under reponame/test by default. Tried passing --extensionTestsPath=./lib/test to either of these to no avail.

Terminal Output:

### VS Code Extension Test Run ###
Current working directory: C:\GitHub\agc-assembly
Running extension tests: C:\GitHub\agc-assembly\.vscode-test\Code C:\GitHub\agc-assembly\test --extensionDevelopmentPath=C:\GitHub\agc-assembly --extensionTestsPath=C:\GitHub\agc-assembly\test


Error: Cannot find module 'C:\GitHub\agc-assembly\test'
@wopian wopian changed the title Can't run CLI tests under different directory Can't run tests under different directory with CLI Jan 1, 2017
@isidorn
Copy link
Contributor

isidorn commented Jan 3, 2017

As far as I understand you are trying to run your tests via the vscode integrated terminal -> thus forwarding to @Tyriar

@isidorn isidorn assigned Tyriar and unassigned isidorn Jan 3, 2017
@weinand
Copy link
Contributor

weinand commented Jan 3, 2017

@wopian when running the tests using the debugger, VS Code shows the exact command that it runs on the debug console. Did you try to run this command from the CLI?

@wopian
Copy link
Author

wopian commented Jan 3, 2017

VS Code shows the exact command that it runs on the debug console. Did you try to run this command from the CLI?

The command it shows is:

'C:\Program Files (x86)\Microsoft VS Code\Code.exe' --debugBrkPluginHost=11634 --extensionDevelopmentPath=c:\github\agc-assembly --extensionTestsPath=c:\github\agc-assembly/lib/test 

Running that in a CLI (PowerShell, MINGW64 or VSC's Integrated Terminal) on Windows gives:

The filename, directory name, or volume label syntax is incorrect.

And of course would require 3 different scripts for tests to be run on Windows, Mac and Linux (CI)


package.json is setup to run the following which gives the terminal output in OP when run with npm test.

"test": "node ./node_modules/vscode/bin/test --silent"

@wopian
Copy link
Author

wopian commented Jan 3, 2017

Inspecting the test binstup in the vscode package, the tests are hard-coded to run in out/test.

var testsFolder;
if (process.env.CODE_TESTS_PATH) {
    testsFolder = process.env.CODE_TESTS_PATH;
} else if (fs.existsSync(path.join(process.cwd(), 'out', 'test'))) {
    testsFolder = path.join(process.cwd(), 'out', 'test'); // TS extension
} else {
    testsFolder = path.join(process.cwd(), 'test'); // JS extension
}

Changing it use lib as the test directory and then running npm test worked perfectly.

var testsFolder;
if (process.env.CODE_TESTS_PATH) {
    testsFolder = process.env.CODE_TESTS_PATH;
} else if (fs.existsSync(path.join(process.cwd(), 'lib', 'test'))) {
    testsFolder = path.join(process.cwd(), 'lib', 'test'); // TS extension
} else {
    testsFolder = path.join(process.cwd(), 'test'); // JS extension
}

Using the CODE_TESTS_PATH isn't viable since I'd need to know the absolute path beforehand.

@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues bug Issue identified by VS Code Team member as probable bug labels Apr 6, 2017
@stevenzeck
Copy link

stevenzeck commented Apr 3, 2018

Anyone ever figure out how to work around this? As @wopian pointed out CODE_TESTS_PATH needs the absolute path which is obviously going to be different on every system.

@weinand weinand closed this as completed Oct 16, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

5 participants