Working with VSCode
If you are using VSCode, use these recommended configurations and settings:
Install Vetur and when you do, you must enable these settings for a good development experience:
- Vetur > Experimental: Template Interpolation Service
- Vetur > Validation: Interpolation
- Vetur > Validation: Template Props
NOTE: Vetur is falling out of favor, Volar might be the new hotness.
To run the server and unit tests in VSCode, add these entries to .vscode/launch.json
{
"name":"Run Server",
"type":"node",
"request":"launch",
"cwd":"${workspaceRoot}",
"runtimeExecutable":"${workspaceRoot}/node_modules/.bin/ts-node-dev",
"args":[
"${workspaceRoot}/src/server/server.ts"
],
"restart":true,
"sourceMaps": true,
"outFiles": ["**/*", "!build/**"]
},
{
"name": "Run Single Unit Test",
"program": "${workspaceFolder}/node_modules/ts-mocha/bin/ts-mocha",
"request": "launch",
"type": "node",
"args": [
"${file}",
"-r",
"tests/utils/setup.ts",
"-p",
"tests/tsconfig.json",
"--no-timeouts",
],
"outFiles": ["**/*", "!build/**", "!node_modules/**"],
},
"Run Single Unit Test" runs the test that your editor has focus on.
Are you still running all tests with npm test
when all you want to test is a single file?
Are you still trying to figure out why your code isn't working with console.log
?
Then you should be using the VSCode Debugger. Here are some steps you can take to debug your app or test. This assumes you already have VSCode set up.
-
Go to the Run and Debug view (CTRL-SHIFT-D)
-
On the very top, to the right of the green arrow is a dropdown. Click the dropdown.
-
Click "Add Configuration..."
If you haven't used
launch.json
yet, then you'll have an empty (initialized) configuration file. -
Add the following two entries as elements of the
configurations
:
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/build/src/server/server.js",
},
{
"type": "node",
"request": "launch",
"name": "Run test in editor",
"program": "${workspaceRoot}/node_modules/mocha/bin/mocha",
"args": [
"--file", "build/tests/utils/Vue.js",
"--no-timeout",
"--colors",
"${workspaceFolder}/build/${relativeFileDirname}/${fileBasenameNoExtension}.js"
],
"internalConsoleOptions": "openOnSessionStart"
},
(Note that these may change as we move to .vue files. Check back here for updates.)
eg
{ // TOP OF FILE
// Use IntelliSense to learn about possible attributes.
// Blah blah blah
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
- Somewhere in this whole process, set breakpoints in your server code (F9 key)
- In the terminal type
npm run build
- Go to the Run and Debug view (CTRL-SHIFT-D)
- Select "Launch Program" from the drop-down
- Click the green arrow.
- ...
- MAGIC
- Set breakpoints in your server code (
F9
key). These breakpoints can be anywhere in server code. - Open the .spec.ts file you want to debug. Don't select another editor view.
- In the terminal type
npm run build && npm run pretest
- Go to the Run and Debug view (CTRL-SHIFT-D)
- Select "Run test in editor" from the drop-down
- Click the green arrow.
- ...
- MAGIC
-
Instead of navigating all the way to the Run and Debug View to launch, pressing F5 will run the last thing you ran. So for instance, if the last thing you ran was a local test, then pressing F5 will run that again. (But if your active editor is a different window, it'll try running that as a test.)
-
Use
Shift-F5
to terminate an app or test early (which you would normally do withCTRL-C
)
The game
Fan Expansions
Development
- Databases
- Development tips
- Docker Setup
- dot env
- Heroku Setup
- Local Setup
- Changing-game-data-for-local-testing
- Adding New Cards
- Working with VSCode
- Postgres Notes
- Translations
Other