Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat(vscode-plugin): use `test-vscode` in `precommit` instead

Matthew Espino6de02844253e
diff --git a/justfile b/justfile
index c1ac1d8de..af7a41f64 100644
--- a/justfile
+++ b/justfile
@@ -41,6 +41,25 @@ build-obsidian:
zip harper-obsidian-plugin.zip manifest.json main.js
+# This assumes that `harper-ls` has been compiled and is located at `target/release`.
+test-vscode:
+ #! /bin/bash
+ set -eo pipefail
+
+ ext_dir="{{justfile_directory()}}/packages/vscode-plugin"
+ bin_dir="${ext_dir}/bin"
+
+ mkdir "$bin_dir"
+ cp "{{justfile_directory()}}/target/release/harper-ls"* "$bin_dir"
+ cd "$ext_dir"
+
+ yarn install -f
+ if [[ "$GITHUB_ACTIONS" == "true" ]] && [[ "$RUNNER_OS" == "Linux" ]]; then
+ xvfb-run --auto-servernum yarn test
+ else
+ yarn test
+ fi
+
# Build and package the Visual Studio Code extension.
# This assumes that `harper-ls` or `harper-ls.exe` exists in `packages/vscode-plugin/bin`.
package-vscode target:
@@ -101,7 +120,7 @@ precommit:
cargo bench
just build-obsidian
- just package-vscode
+ just test-vscode
just build-web
# Install `harper-cli` and `harper-ls` to your machine via `cargo`
diff --git a/packages/vscode-plugin/src/tests/suite/integration.test.ts b/packages/vscode-plugin/src/tests/suite/integration.test.ts
index ece63a78a..b4c341b25 100644
--- a/packages/vscode-plugin/src/tests/suite/integration.test.ts
+++ b/packages/vscode-plugin/src/tests/suite/integration.test.ts
@@ -13,7 +13,7 @@ import {
workspace
} from 'vscode';
-describe('Integration tests', () => {
+describe('Harper Extension', () => {
let harper: Extension<void>;
let documentUri: Uri;
@@ -26,21 +26,21 @@ describe('Integration tests', () => {
await window.showTextDocument(await workspace.openTextDocument(documentUri));
// Wait for `harper-ls` to start
- await sleep(100);
+ await sleep(500);
});
- it('Runs', () => {
+ it('runs', () => {
expect(harper.isActive).toBe(true);
});
- it('Gives correct diagnostics', () => {
+ it('gives correct diagnostics', () => {
const actual = languages.getDiagnostics(documentUri);
const expected: Diagnostic[] = [
{
source: 'Harper',
message: 'Did you mean to repeat this word?',
severity: DiagnosticSeverity.Information,
- range: new Range(new Position(2, 43), new Position(2, 48))
+ range: new Range(new Position(2, 39), new Position(2, 48))
},
{
source: 'Harper',
@@ -59,11 +59,11 @@ describe('Integration tests', () => {
}
});
- it('Updates diagnostics on configuration change', async () => {
+ it('updates diagnostics on configuration change', async () => {
const config = workspace.getConfiguration('harper-ls.linters');
await config.update('repeated_words', false, ConfigurationTarget.Workspace);
// Wait for `harper-ls` to restart
- await sleep(500);
+ await sleep(1000);
const actual = languages.getDiagnostics(documentUri);
const expected: Diagnostic[] = [