software-mansion / react-native-ide

https://ide.swmansion.com
Other
705 stars 21 forks source link

Add tests #371

Closed jakub-gonet closed 2 weeks ago

jakub-gonet commented 2 weeks ago

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:

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:

vercel[bot] commented 2 weeks ago

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 commented 2 weeks ago

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.