Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Unit test error 'cannot find module vscode' #2311

Closed
taseri opened this issue Feb 8, 2019 · 1 comment · Fixed by #2310
Closed

Unit test error 'cannot find module vscode' #2311

taseri opened this issue Feb 8, 2019 · 1 comment · Fixed by #2310

Comments

@taseri
Copy link
Contributor

taseri commented Feb 8, 2019

I ran the unit test configuration on CI to check this problem wasn't just on my machine (#2310 ).

Steps to Reproduce:

  1. clone the project
  2. run npm install
  3. run npm run vscode:prepublish
  4. either run the Unit Tests config from the debug viewlet in the IDE or run from prompt npm node ./node_modules/mocha/bin/_mocha -u tdd --timeout 5000 --colors ./out/test/unit

The error from Travis is:

Error: Cannot find module 'vscode'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/travis/gopath/src/github.com/Microsoft/vscode-go/out/src/util.js:7:16)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/travis/gopath/src/github.com/Microsoft/vscode-go/out/test/unit/utils.test.js:7:16)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at /Users/travis/gopath/src/github.com/Microsoft/vscode-go/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/travis/gopath/src/github.com/Microsoft/vscode-go/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/Users/travis/gopath/src/github.com/Microsoft/vscode-go/node_modules/mocha/lib/mocha.js:536:10)
    at Object.<anonymous> (/Users/travis/gopath/src/github.com/Microsoft/vscode-go/node_modules/mocha/bin/_mocha:573:18)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.runMain (module.js:611:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:160:9)
    at bootstrap_node.js:507:3

It looks like the tests in the file 'utils.test.ts' are integration tests and should be moved out of the unit test folder (the utils.test.ts have the dependency on the vscode module). Also I think it would make sense to permanently add the the unit test run to Travis so this would get picked up if it happened again. There may be more to this in terms of a discussion around the value of unit tests vs integration tests when developing a VS Code extension.

@taseri
Copy link
Contributor Author

taseri commented Feb 10, 2019

The PR #2310 is to fix this issue. Note, people working on the extension project may need to clean the old utils.test.js file out of the out/test/unit folder to get a green unit test run.

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant