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

Add tests #371

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Add tests #371

merged 1 commit into from
Jun 12, 2024

Conversation

jakub-gonet
Copy link
Member

@jakub-gonet jakub-gonet commented Jun 12, 2024

Adds vscode-test package that allows for testing extension.

We configure it's user data directory because it creates a socket and socket's path is used as a key. Unfortunately, it only supports 103 characters so long paths get trimmed and it doesn't clean the socket before next run.

For tests, it uses mocha. We additionally use sinon for creating mocks.

Mocha only supports JS files, we transpile them using TS in the dist directory, under test/. We ignore this directory when creating a VSIX package.

Tests are structured as follows:

  • integration-tests directory for more end-to-end testing.
  • XXX.test.ts files next to implementation to unit test it.

To run tests execute npm run test command which rebuilds webview and extension, then running tests.
It expects simulator executable in the dist directory, you can regenerate it with npm run build:sim-server-debug.

Few sources that can be used as a reference for writing tests:

Copy link

vercel bot commented Jun 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2024 2:10pm

@jakub-gonet
Copy link
Member Author

It's possible to run tests without running VSC instance but we'd need to mock vscode imports somehow. I left it for the future as it's good enough in the current shape.

Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@jakub-gonet jakub-gonet merged commit 9af091a into main Jun 12, 2024
3 checks passed
@jakub-gonet jakub-gonet deleted the jgonet/add-jest branch June 12, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants