diff --git a/package.json b/package.json index fabced50..42003eec 100644 --- a/package.json +++ b/package.json @@ -117,13 +117,13 @@ "devDependencies": { "@types/fs-extra": "^9.0.13", "@types/glob": "^7.2.0", - "@types/mocha": "^9.1.0", "@types/node": "14.x", "@types/semver": "^7.3.9", "@types/vscode": "^1.59.0", "@types/ws": "^8.5.3", "@typescript-eslint/eslint-plugin": "^5.12.1", "@typescript-eslint/parser": "^5.12.1", + "@vitest/ws-client": "^0.12.6", "@vscode/test-electron": "^2.1.2", "@vueuse/core": "^8.4.2", "eslint": "^8.9.0", @@ -133,8 +133,7 @@ "tsup": "^5.12.7", "typescript": "^4.5.5", "vite": "^2.8.6", - "vitest": "latest", - "@vitest/ws-client": "^0.12.6" + "vitest": "latest" }, "dependencies": { "@babel/parser": "^7.17.3", diff --git a/samples/basic/package.json b/samples/basic/package.json index 3fe82ba8..db3c9e60 100644 --- a/samples/basic/package.json +++ b/samples/basic/package.json @@ -10,6 +10,9 @@ "license": "ISC", "devDependencies": { "vite": "^2.8.6", - "vitest": "^0.8.0" + "vitest": "latest" + }, + "dependencies": { + "birpc": "^0.2.2" } } diff --git a/samples/basic/test/add.test.ts b/samples/basic/test/add.test.ts index ab2fed04..c698f2d0 100644 --- a/samples/basic/test/add.test.ts +++ b/samples/basic/test/add.test.ts @@ -10,7 +10,7 @@ describe("addition", () => { it("should failed", async () => { await new Promise((r) => setTimeout(r, 100)); - expect(1 + 2).toBe(2); + expect(1 + 2).toBe(3); }); it.skip("skipped", () => { diff --git a/samples/basic/vite.config.ts b/samples/basic/vite.config.ts index 5f8ad2b4..ef7150c8 100644 --- a/samples/basic/vite.config.ts +++ b/samples/basic/vite.config.ts @@ -6,6 +6,7 @@ import { defineConfig } from "vite"; export default defineConfig({ test: { - include: ["src/should_included_test.ts", "test/**"], + include: ["src/should_included_test.ts", "test/**/*.test.ts"], + exclude: ["test/ignored.test.ts"], }, }); diff --git a/samples/basic/yarn.lock b/samples/basic/yarn.lock index d627b2cf..f0d4499b 100644 --- a/samples/basic/yarn.lock +++ b/samples/basic/yarn.lock @@ -9,16 +9,26 @@ dependencies: "@types/chai" "*" -"@types/chai@*", "@types/chai@^4.3.0": +"@types/chai@*": version "4.3.0" resolved "https://registry.npmmirror.com/@types/chai/-/chai-4.3.0.tgz#23509ebc1fa32f1b4d50d6a66c4032d5b8eaabdc" integrity sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw== +"@types/chai@^4.3.1": + version "4.3.1" + resolved "https://registry.npmmirror.com/@types/chai/-/chai-4.3.1.tgz#e2c6e73e0bdeb2521d00756d099218e9f5d90a04" + integrity sha512-/zPMqDkzSZ8t3VtxOa4KPq7uzzW978M9Tvh+j7GHKuo6k6GTLxPJ4J5gE5cjfJ26pnXst0N5Hax8Sr0T2Mi9zQ== + assertion-error@^1.1.0: version "1.1.0" resolved "https://registry.npmmirror.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== +birpc@^0.2.2: + version "0.2.2" + resolved "https://registry.npmmirror.com/birpc/-/birpc-0.2.2.tgz#7e033234e946e2772fa01dfb897f31dd69184acd" + integrity sha512-59Tc83t28ulRZpuPz4JO+ry1EhBsoy81etx1kboBSzkx7hGExqUzIYxwDLcj1Ou8f4P/ZNacqDaat1ubBUbInw== + chai@^4.3.6: version "4.3.6" resolved "https://registry.npmmirror.com/chai/-/chai-4.3.6.tgz#ffe4ba2d9fa9d6680cc0b370adae709ec9011e9c" @@ -49,101 +59,201 @@ esbuild-android-64@0.14.25: resolved "https://registry.npmmirror.com/esbuild-android-64/-/esbuild-android-64-0.14.25.tgz#d532d38cb5fe0ae45167ce35f4bbc784c636be40" integrity sha512-L5vCUk7TzFbBnoESNoXjU3x9+/+7TDIE/1mTfy/erAfvZAqC+S3sp/Qa9wkypFMcFvN9FzvESkTlpeQDolREtQ== +esbuild-android-64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-android-64/-/esbuild-android-64-0.14.39.tgz#09f12a372eed9743fd77ff6d889ac14f7b340c21" + integrity sha512-EJOu04p9WgZk0UoKTqLId9VnIsotmI/Z98EXrKURGb3LPNunkeffqQIkjS2cAvidh+OK5uVrXaIP229zK6GvhQ== + esbuild-android-arm64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-android-arm64/-/esbuild-android-arm64-0.14.25.tgz#9c5bb3366aabfd14a1c726d36978b79441dfcb6e" integrity sha512-4jv5xPjM/qNm27T5j3ZEck0PvjgQtoMHnz4FzwF5zNP56PvY2CT0WStcAIl6jNlsuDdN63rk2HRBIsO6xFbcFw== +esbuild-android-arm64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-android-arm64/-/esbuild-android-arm64-0.14.39.tgz#f608d00ea03fe26f3b1ab92a30f99220390f3071" + integrity sha512-+twajJqO7n3MrCz9e+2lVOnFplRsaGRwsq1KL/uOy7xK7QdRSprRQcObGDeDZUZsacD5gUkk6OiHiYp6RzU3CA== + esbuild-darwin-64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-darwin-64/-/esbuild-darwin-64-0.14.25.tgz#05dcdb6d884f427039ffee5e92ff97527e56c26d" integrity sha512-TGp8tuudIxOyWd1+8aYPxQmC1ZQyvij/AfNBa35RubixD0zJ1vkKHVAzo0Zao1zcG6pNqiSyzfPto8vmg0s7oA== +esbuild-darwin-64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-darwin-64/-/esbuild-darwin-64-0.14.39.tgz#31528daa75b4c9317721ede344195163fae3e041" + integrity sha512-ImT6eUw3kcGcHoUxEcdBpi6LfTRWaV6+qf32iYYAfwOeV+XaQ/Xp5XQIBiijLeo+LpGci9M0FVec09nUw41a5g== + esbuild-darwin-arm64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.25.tgz#28e080da4ea0cfe9498071e7f8060498caee1a95" integrity sha512-oTcDgdm0MDVEmw2DWu8BV68pYuImpFgvWREPErBZmNA4MYKGuBRaCiJqq6jZmBR1x+3y1DWCjez+5uLtuAm6mw== +esbuild-darwin-arm64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.39.tgz#247f770d86d90a215fa194f24f90e30a0bd97245" + integrity sha512-/fcQ5UhE05OiT+bW5v7/up1bDsnvaRZPJxXwzXsMRrr7rZqPa85vayrD723oWMT64dhrgWeA3FIneF8yER0XTw== + esbuild-freebsd-64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.25.tgz#200d3664a3b945bc9fdcba73614b49a11ebd1cfa" integrity sha512-ueAqbnMZ8arnuLH8tHwTCQYeptnHOUV7vA6px6j4zjjQwDx7TdP7kACPf3TLZLdJQ3CAD1XCvQ2sPhX+8tacvQ== +esbuild-freebsd-64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.39.tgz#479414d294905055eb396ebe455ed42213284ee0" + integrity sha512-oMNH8lJI4wtgN5oxuFP7BQ22vgB/e3Tl5Woehcd6i2r6F3TszpCnNl8wo2d/KvyQ4zvLvCWAlRciumhQg88+kQ== + esbuild-freebsd-arm64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.25.tgz#624b08c5da6013bdc312aaa23c4ff409580f5c3c" integrity sha512-+ZVWud2HKh+Ob6k/qiJWjBtUg4KmJGGmbvEXXW1SNKS7hW7HU+Zq2ZCcE1akFxOPkVB+EhOty/sSek30tkCYug== +esbuild-freebsd-arm64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.39.tgz#cedeb10357c88533615921ae767a67dc870a474c" + integrity sha512-1GHK7kwk57ukY2yI4ILWKJXaxfr+8HcM/r/JKCGCPziIVlL+Wi7RbJ2OzMcTKZ1HpvEqCTBT/J6cO4ZEwW4Ypg== + esbuild-linux-32@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-linux-32/-/esbuild-linux-32-0.14.25.tgz#0238e597eb0b60aa06c7e98fccbbfd6bb9a0d6c5" integrity sha512-3OP/lwV3kCzEz45tobH9nj+uE4ubhGsfx+tn0L26WAGtUbmmcRpqy7XRG/qK7h1mClZ+eguIANcQntYMdYklfw== +esbuild-linux-32@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-linux-32/-/esbuild-linux-32-0.14.39.tgz#d9f008c4322d771f3958f59c1eee5a05cdf92485" + integrity sha512-g97Sbb6g4zfRLIxHgW2pc393DjnkTRMeq3N1rmjDUABxpx8SjocK4jLen+/mq55G46eE2TA0MkJ4R3SpKMu7dg== + esbuild-linux-64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-linux-64/-/esbuild-linux-64-0.14.25.tgz#8a8b8cf47dfce127c858e71229d9a385a82c62e8" integrity sha512-+aKHdHZmX9qwVlQmu5xYXh7GsBFf4TWrePgeJTalhXHOG7NNuUwoHmketGiZEoNsWyyqwH9rE5BC+iwcLY30Ug== +esbuild-linux-64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-linux-64/-/esbuild-linux-64-0.14.39.tgz#ba58d7f66858913aeb1ab5c6bde1bbd824731795" + integrity sha512-4tcgFDYWdI+UbNMGlua9u1Zhu0N5R6u9tl5WOM8aVnNX143JZoBZLpCuUr5lCKhnD0SCO+5gUyMfupGrHtfggQ== + esbuild-linux-arm64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.25.tgz#7ac94371418a2640ba413bc1700aaedeb2794e52" integrity sha512-UxfenPx/wSZx55gScCImPtXekvZQLI2GW3qe5dtlmU7luiqhp5GWPzGeQEbD3yN3xg/pHc671m5bma5Ns7lBHw== +esbuild-linux-arm64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.39.tgz#708785a30072702b5b1c16b65cf9c25c51202529" + integrity sha512-23pc8MlD2D6Px1mV8GMglZlKgwgNKAO8gsgsLLcXWSs9lQsCYkIlMo/2Ycfo5JrDIbLdwgP8D2vpfH2KcBqrDQ== + esbuild-linux-arm@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-linux-arm/-/esbuild-linux-arm-0.14.25.tgz#034bd18e9310b9f010c89f90ef7f05706689600b" integrity sha512-aTLcE2VBoLydL943REcAcgnDi3bHtmULSXWLbjtBdtykRatJVSxKMjK9YlBXUZC4/YcNQfH7AxwVeQr9fNxPhw== +esbuild-linux-arm@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-linux-arm/-/esbuild-linux-arm-0.14.39.tgz#4e8b5deaa7ab60d0d28fab131244ef82b40684f4" + integrity sha512-t0Hn1kWVx5UpCzAJkKRfHeYOLyFnXwYynIkK54/h3tbMweGI7dj400D1k0Vvtj2u1P+JTRT9tx3AjtLEMmfVBQ== + esbuild-linux-mips64le@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.25.tgz#05f98a8cf6b578eab6b4e6b0ab094f37530934f4" integrity sha512-wLWYyqVfYx9Ur6eU5RT92yJVsaBGi5RdkoWqRHOqcJ38Kn60QMlcghsKeWfe9jcYut8LangYZ98xO1LxIoSXrQ== +esbuild-linux-mips64le@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.39.tgz#6f3bf3023f711084e5a1e8190487d2020f39f0f7" + integrity sha512-epwlYgVdbmkuRr5n4es3B+yDI0I2e/nxhKejT9H0OLxFAlMkeQZxSpxATpDc9m8NqRci6Kwyb/SfmD1koG2Zuw== + esbuild-linux-ppc64le@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.25.tgz#46fd0add8d8535678439d7a9c2876ad20042d952" integrity sha512-0dR6Csl6Zas3g4p9ULckEl8Mo8IInJh33VCJ3eaV1hj9+MHGdmDOakYMN8MZP9/5nl+NU/0ygpd14cWgy8uqRw== +esbuild-linux-ppc64le@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.39.tgz#900e718a4ea3f6aedde8424828eeefdd4b48d4b9" + integrity sha512-W/5ezaq+rQiQBThIjLMNjsuhPHg+ApVAdTz2LvcuesZFMsJoQAW2hutoyg47XxpWi7aEjJGrkS26qCJKhRn3QQ== + esbuild-linux-riscv64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.25.tgz#ea2e986f0f3e5df73c635135dd778051734fc605" integrity sha512-J4d20HDmTrgvhR0bdkDhvvJGaikH3LzXQnNaseo8rcw9Yqby9A90gKUmWpfwqLVNRILvNnAmKLfBjCKU9ajg8w== +esbuild-linux-riscv64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.39.tgz#dcbff622fa37047a75d2ff7a1d8d2949d80277e4" + integrity sha512-IS48xeokcCTKeQIOke2O0t9t14HPvwnZcy+5baG13Z1wxs9ZrC5ig5ypEQQh4QMKxURD5TpCLHw2W42CLuVZaA== + esbuild-linux-s390x@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.25.tgz#efe89486e9a1b1508925048076e3f3a6698aa6a3" integrity sha512-YI2d5V6nTE73ZnhEKQD7MtsPs1EtUZJ3obS21oxQxGbbRw1G+PtJKjNyur+3t6nzHP9oTg6GHQ3S3hOLLmbDIQ== +esbuild-linux-s390x@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.39.tgz#3f725a7945b419406c99d93744b28552561dcdfd" + integrity sha512-zEfunpqR8sMomqXhNTFEKDs+ik7HC01m3M60MsEjZOqaywHu5e5682fMsqOlZbesEAAaO9aAtRBsU7CHnSZWyA== + esbuild-netbsd-64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.25.tgz#439fe27d8ee3b5887501ee63988e85f920107db6" integrity sha512-TKIVgNWLUOkr+Exrye70XTEE1lJjdQXdM4tAXRzfHE9iBA7LXWcNtVIuSnphTqpanPzTDFarF0yqq4kpbC6miA== +esbuild-netbsd-64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.39.tgz#e10e40b6a765798b90d4eb85901cc85c8b7ff85e" + integrity sha512-Uo2suJBSIlrZCe4E0k75VDIFJWfZy+bOV6ih3T4MVMRJh1lHJ2UyGoaX4bOxomYN3t+IakHPyEoln1+qJ1qYaA== + esbuild-openbsd-64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.25.tgz#31ebf616aadf6e60674469f2b92cec92280d9930" integrity sha512-QgFJ37A15D7NIXBTYEqz29+uw3nNBOIyog+3kFidANn6kjw0GHZ0lEYQn+cwjyzu94WobR+fes7cTl/ZYlHb1A== +esbuild-openbsd-64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.39.tgz#935ec143f75ce10bd9cdb1c87fee00287eb0edbc" + integrity sha512-secQU+EpgUPpYjJe3OecoeGKVvRMLeKUxSMGHnK+aK5uQM3n1FPXNJzyz1LHFOo0WOyw+uoCxBYdM4O10oaCAA== + esbuild-sunos-64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-sunos-64/-/esbuild-sunos-64-0.14.25.tgz#815e4f936d74970292a63ccfd5791fe5e3569f5f" integrity sha512-rmWfjUItYIVlqr5EnTH1+GCxXiBOC42WBZ3w++qh7n2cS9Xo0lO5pGSG2N+huOU2fX5L+6YUuJ78/vOYvefeFw== +esbuild-sunos-64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-sunos-64/-/esbuild-sunos-64-0.14.39.tgz#0e7aa82b022a2e6d55b0646738b2582c2d72c3c0" + integrity sha512-qHq0t5gePEDm2nqZLb+35p/qkaXVS7oIe32R0ECh2HOdiXXkj/1uQI9IRogGqKkK+QjDG+DhwiUw7QoHur/Rwg== + esbuild-windows-32@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-windows-32/-/esbuild-windows-32-0.14.25.tgz#189e14df2478f2c193c86968ab1fb54e1ceaafd2" integrity sha512-HGAxVUofl3iUIz9W10Y9XKtD0bNsK9fBXv1D55N/ljNvkrAYcGB8YCm0v7DjlwtyS6ws3dkdQyXadbxkbzaKOA== +esbuild-windows-32@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-windows-32/-/esbuild-windows-32-0.14.39.tgz#3f1538241f31b538545f4b5841b248cac260fa35" + integrity sha512-XPjwp2OgtEX0JnOlTgT6E5txbRp6Uw54Isorm3CwOtloJazeIWXuiwK0ONJBVb/CGbiCpS7iP2UahGgd2p1x+Q== + esbuild-windows-64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-windows-64/-/esbuild-windows-64-0.14.25.tgz#3d5fbfdc3856850bb47439299e3b60dd18be111f" integrity sha512-TirEohRkfWU9hXLgoDxzhMQD1g8I2mOqvdQF2RS9E/wbkORTAqJHyh7wqGRCQAwNzdNXdg3JAyhQ9/177AadWA== +esbuild-windows-64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-windows-64/-/esbuild-windows-64-0.14.39.tgz#b100c59f96d3c2da2e796e42fee4900d755d3e03" + integrity sha512-E2wm+5FwCcLpKsBHRw28bSYQw0Ikxb7zIMxw3OPAkiaQhLVr3dnVO8DofmbWhhf6b97bWzg37iSZ45ZDpLw7Ow== + esbuild-windows-arm64@0.14.25: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.25.tgz#8b243cbbad8a86cf98697da9ccb88c05df2ef458" integrity sha512-4ype9ERiI45rSh+R8qUoBtaj6kJvUOI7oVLhKqPEpcF4Pa5PpT3hm/mXAyotJHREkHpM87PAJcA442mLnbtlNA== +esbuild-windows-arm64@0.14.39: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.39.tgz#00268517e665b33c89778d61f144e4256b39f631" + integrity sha512-sBZQz5D+Gd0EQ09tZRnz/PpVdLwvp/ufMtJ1iDFYddDaPpZXKqPyaxfYBLs3ueiaksQ26GGa7sci0OqFzNs7KA== + esbuild@^0.14.14: version "0.14.25" resolved "https://registry.npmmirror.com/esbuild/-/esbuild-0.14.25.tgz#ddb9d47b91ca76abb7d850ce3dfed0bc3dc88d16" @@ -170,6 +280,32 @@ esbuild@^0.14.14: esbuild-windows-64 "0.14.25" esbuild-windows-arm64 "0.14.25" +esbuild@^0.14.27: + version "0.14.39" + resolved "https://registry.npmmirror.com/esbuild/-/esbuild-0.14.39.tgz#c926b2259fe6f6d3a94f528fb42e103c5a6d909a" + integrity sha512-2kKujuzvRWYtwvNjYDY444LQIA3TyJhJIX3Yo4+qkFlDDtGlSicWgeHVJqMUP/2sSfH10PGwfsj+O2ro1m10xQ== + optionalDependencies: + esbuild-android-64 "0.14.39" + esbuild-android-arm64 "0.14.39" + esbuild-darwin-64 "0.14.39" + esbuild-darwin-arm64 "0.14.39" + esbuild-freebsd-64 "0.14.39" + esbuild-freebsd-arm64 "0.14.39" + esbuild-linux-32 "0.14.39" + esbuild-linux-64 "0.14.39" + esbuild-linux-arm "0.14.39" + esbuild-linux-arm64 "0.14.39" + esbuild-linux-mips64le "0.14.39" + esbuild-linux-ppc64le "0.14.39" + esbuild-linux-riscv64 "0.14.39" + esbuild-linux-s390x "0.14.39" + esbuild-netbsd-64 "0.14.39" + esbuild-openbsd-64 "0.14.39" + esbuild-sunos-64 "0.14.39" + esbuild-windows-32 "0.14.39" + esbuild-windows-64 "0.14.39" + esbuild-windows-arm64 "0.14.39" + fsevents@~2.3.2: version "2.3.2" resolved "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" @@ -216,6 +352,11 @@ nanoid@^3.3.1: resolved "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== +nanoid@^3.3.3: + version "3.3.4" + resolved "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" + integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== + path-parse@^1.0.7: version "1.0.7" resolved "https://registry.npmmirror.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" @@ -231,6 +372,15 @@ picocolors@^1.0.0: resolved "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== +postcss@^8.4.13: + version "8.4.13" + resolved "https://registry.npmmirror.com/postcss/-/postcss-8.4.13.tgz#7c87bc268e79f7f86524235821dfdf9f73e5d575" + integrity sha512-jtL6eTBrza5MPzy8oJLFuUscHDXTV5KcLlqAWHl5q5WYRfnNRGSmOZmOZ1T6Gy7A99mOZfqungmZMpMmCVJ8ZA== + dependencies: + nanoid "^3.3.3" + picocolors "^1.0.0" + source-map-js "^1.0.2" + postcss@^8.4.6: version "8.4.8" resolved "https://registry.npmmirror.com/postcss/-/postcss-8.4.8.tgz#dad963a76e82c081a0657d3a2f3602ce10c2e032" @@ -266,15 +416,15 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== -tinypool@^0.1.2: - version "0.1.2" - resolved "https://registry.npmmirror.com/tinypool/-/tinypool-0.1.2.tgz#5b1d5f5bb403afac8c67000047951ce76342fda7" - integrity sha512-fvtYGXoui2RpeMILfkvGIgOVkzJEGediv8UJt7TxdAOY8pnvUkFg/fkvqTfXG9Acc9S17Cnn1S4osDc2164guA== +tinypool@^0.1.3: + version "0.1.3" + resolved "https://registry.npmmirror.com/tinypool/-/tinypool-0.1.3.tgz#b5570b364a1775fd403de5e7660b325308fee26b" + integrity sha512-2IfcQh7CP46XGWGGbdyO4pjcKqsmVqFAPcXfPxcPXmOWt9cYkTP9HcDmGgsfijYoAEc4z9qcpM/BaBz46Y9/CQ== -tinyspy@^0.3.0: - version "0.3.0" - resolved "https://registry.npmmirror.com/tinyspy/-/tinyspy-0.3.0.tgz#51bcc198173385c50416df791cd10c192078cb36" - integrity sha512-c5uFHqtUp74R2DJE3/Efg0mH5xicmgziaQXMm/LvuuZn3RdpADH32aEGDRyCzObXT1DNfwDMqRQ/Drh1MlO12g== +tinyspy@^0.3.2: + version "0.3.2" + resolved "https://registry.npmmirror.com/tinyspy/-/tinyspy-0.3.2.tgz#2f95cb14c38089ca690385f339781cd35faae566" + integrity sha512-2+40EP4D3sFYy42UkgkFFB+kiX2Tg3URG/lVvAZFfLxgGpnWl5qQJuBw1gaLttq8UOS+2p3C0WrhJnQigLTT2Q== type-detect@^4.0.0, type-detect@^4.0.5: version "4.0.8" @@ -293,15 +443,27 @@ vite@^2.8.6: optionalDependencies: fsevents "~2.3.2" -vitest@^0.8.0: - version "0.8.0" - resolved "https://registry.npmmirror.com/vitest/-/vitest-0.8.0.tgz#fffd4d1334268a7311c0bfd891a68263a5cb206f" - integrity sha512-8m8OufAQWXlNpjm5dTe5Lc60zruguKJljunveueYrd4aoeXaQvggLX0SPmIW3G6PDtnBdNEynSi+6pibjnutQA== +vite@^2.9.8: + version "2.9.9" + resolved "https://registry.npmmirror.com/vite/-/vite-2.9.9.tgz#8b558987db5e60fedec2f4b003b73164cb081c5e" + integrity sha512-ffaam+NgHfbEmfw/Vuh6BHKKlI/XIAhxE5QSS7gFLIngxg171mg1P3a4LSRME0z2ZU1ScxoKzphkipcYwSD5Ew== + dependencies: + esbuild "^0.14.27" + postcss "^8.4.13" + resolve "^1.22.0" + rollup "^2.59.0" + optionalDependencies: + fsevents "~2.3.2" + +vitest@latest: + version "0.12.6" + resolved "https://registry.npmmirror.com/vitest/-/vitest-0.12.6.tgz#9de2cca78e97effe5395230486ebd3830d0721dd" + integrity sha512-YWbCTv0XKBuBw5YtuW/iufuguoi8QhGpYyi2g57Oo7akpscMkkWTAaZGgY0ux1oJJtO/pc/8GFt0EF32WFBUUQ== dependencies: - "@types/chai" "^4.3.0" + "@types/chai" "^4.3.1" "@types/chai-subset" "^1.3.3" chai "^4.3.6" local-pkg "^0.4.1" - tinypool "^0.1.2" - tinyspy "^0.3.0" - vite "^2.8.6" + tinypool "^0.1.3" + tinyspy "^0.3.2" + vite "^2.9.8" diff --git a/src/discover.ts b/src/discover.ts index 8be185e2..d01dfff4 100644 --- a/src/discover.ts +++ b/src/discover.ts @@ -117,7 +117,9 @@ export class TestFileDiscoverer extends vscode.Disposable { path: string, ) { const { data } = this.getOrCreateFile(controller, vscode.Uri.file(path)); - data.updateFromDisk(controller); + if (!data.resolved) { + data.updateFromDisk(controller); + } return data; } @@ -210,7 +212,9 @@ export function discoverTestFromFileContent( const top = ancestors.pop(); if (top) { top.item.children.replace(top.children); - (top.data as (TestFile | TestDescribe)).children = top.dataChildren; + (top.data as (TestFile | TestDescribe)).children = [ + ...top.dataChildren, + ]; } parent = ancestors[ancestors.length - 1]; @@ -279,6 +283,9 @@ export function discoverTestFromFileContent( const top = ancestors.pop(); if (top) { top.item.children.replace(top.children); + (top.data as (TestFile | TestDescribe)).children = [ + ...top.dataChildren, + ]; } } } diff --git a/src/pure/watch/client.ts b/src/pure/watch/client.ts index b35aa91a..43b6768c 100644 --- a/src/pure/watch/client.ts +++ b/src/pure/watch/client.ts @@ -1,7 +1,7 @@ -import { createClient } from "@vitest/ws-client"; import WebSocket from "ws"; import { computed, effect, reactive, ref, shallowRef } from "@vue/reactivity"; import type { ResolvedConfig, WebSocketEvents } from "vitest"; +import { createClient } from "./ws-client"; type WebSocketStatus = "OPEN" | "CONNECTING" | "CLOSED"; (globalThis as any).WebSocket = WebSocket; diff --git a/src/pure/watch/ws-client.ts b/src/pure/watch/ws-client.ts new file mode 100644 index 00000000..224f8572 --- /dev/null +++ b/src/pure/watch/ws-client.ts @@ -0,0 +1,189 @@ +// this file is copied from vitest with a few modifications; +import { shallowReactive } from "@vue/reactivity"; +import type { BirpcReturn } from "birpc"; +import { createBirpc } from "birpc"; +import { parse, stringify } from "flatted"; +// eslint-disable-next-line no-restricted-imports +import type { WebSocketEvents, WebSocketHandlers } from "vitest"; +import type { + ErrorWithDiff, + File, + Task, + TaskResultPack, + UserConsoleLog, +} from "vitest"; + +class StateManager { + filesMap = new Map(); + idMap = new Map(); + taskFileMap = new WeakMap(); + errorsSet = new Set(); + + catchError(err: unknown, type: string) { + (err as any).type = type; + this.errorsSet.add(err); + } + + clearErrors() { + this.errorsSet.clear(); + } + + getUnhandledErrors() { + return Array.from(this.errorsSet.values()); + } + + getFiles(keys?: string[]): File[] { + if (keys) { + return keys.map((key) => this.filesMap.get(key)!); + } + return Array.from(this.filesMap.values()); + } + + getFilepaths(): string[] { + return Array.from(this.filesMap.keys()); + } + + getFailedFilepaths() { + return this.getFiles() + .filter((i) => i.result?.state === "fail") + .map((i) => i.filepath); + } + + collectFiles(files: File[] = []) { + files.forEach((file) => { + this.filesMap.set(file.filepath, file); + this.updateId(file); + }); + } + + updateId(task: Task) { + if (this.idMap.get(task.id) === task) { + return; + } + this.idMap.set(task.id, task); + if (task.type === "suite") { + task.tasks.forEach((task) => { + this.updateId(task); + }); + } + } + + updateTasks(packs: TaskResultPack[]) { + for (const [id, result] of packs) { + if (this.idMap.has(id)) { + this.idMap.get(id)!.result = result; + } + } + } + + updateUserLog(log: UserConsoleLog) { + const task = log.taskId && this.idMap.get(log.taskId); + if (task) { + if (!task.logs) { + task.logs = []; + } + task.logs.push(log); + } + } +} +export interface VitestClientOptions { + handlers?: Partial; + autoReconnect?: boolean; + reconnectInterval?: number; + reconnectTries?: number; + reactive?: (v: T) => T; + ref?: (v: T) => { value: T }; + WebSocketConstructor?: typeof WebSocket; +} + +export interface VitestClient { + ws: WebSocket; + state: StateManager; + rpc: BirpcReturn; + waitForConnection(): Promise; + reconnect(): Promise; +} + +export function createClient(url: string, options: VitestClientOptions = {}) { + const { + handlers = {}, + autoReconnect = true, + reconnectInterval = 2000, + reconnectTries = 10, + reactive = (v) => v, + WebSocketConstructor = globalThis.WebSocket, + } = options; + + let tries = reconnectTries; + const ctx = reactive({ + ws: shallowReactive(new WebSocketConstructor(url)), + state: new StateManager(), + waitForConnection, + reconnect, + }) as VitestClient; + + ctx.state.filesMap = reactive(ctx.state.filesMap); + ctx.state.idMap = reactive(ctx.state.idMap); + + let onMessage: Function; + ctx.rpc = createBirpc( + { + onCollected(files) { + ctx.state.collectFiles(files); + handlers.onCollected?.(files); + }, + onTaskUpdate(packs) { + ctx.state.updateTasks(packs); + handlers.onTaskUpdate?.(packs); + }, + onUserConsoleLog(log) { + ctx.state.updateUserLog(log); + }, + onFinished(files) { + handlers.onFinished?.(files); + }, + }, + { + post: (msg) => ctx.ws.send(msg), + on: (fn) => onMessage = fn, + serialize: stringify, + deserialize: parse, + }, + ); + + let openPromise: Promise; + + function reconnect(reset = false) { + if (reset) { + tries = reconnectTries; + } + ctx.ws = shallowReactive(new WebSocketConstructor(url)); + registerWS(); + } + + function registerWS() { + openPromise = new Promise((resolve) => { + ctx.ws.addEventListener("open", () => { + tries = reconnectTries; + resolve(); + }); + }); + ctx.ws.addEventListener("message", (v) => { + onMessage(v.data); + }); + ctx.ws.addEventListener("close", () => { + tries -= 1; + if (autoReconnect && tries > 0) { + setTimeout(reconnect, reconnectInterval); + } + }); + } + + registerWS(); + + function waitForConnection() { + return openPromise; + } + + return ctx; +} diff --git a/src/watch.ts b/src/watch.ts index ed1b08a1..b5b10fc4 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -13,9 +13,15 @@ import { TestFileDiscoverer } from "./discover"; import { effect, ref } from "@vue/reactivity"; import { ChildProcess, spawn } from "child_process"; import { getTasks } from "@vitest/ws-client"; -import { TestCase, TestDescribe, TestFile } from "./TestData"; +import { + TestCase, + TestDescribe, + TestFile, + WEAKMAP_TEST_DATA, +} from "./TestData"; import { chunksToLinesAsync } from "@rauschma/stringio"; import { isWindows } from "./pure/platform"; +import { file } from "@babel/types"; export class TestWatcher extends Disposable { static cache: undefined | TestWatcher; @@ -63,6 +69,19 @@ export class TestWatcher extends Disposable { detached: !isWindows, }); + this.process.on("error", (err) => { + console.error("WATCH PROCESS", err.toString()); + console.log(err.stack); + }); + + this.process.on("close", () => { + console.log("WATCH PROCESS CLOSE"); + }); + + this.process.on("exit", () => { + console.log("WATCH PROCESS EXIT"); + }); + (async () => { for await (const line of chunksToLinesAsync(process.stdout)) { console.log("WATCH PROCESS", line); @@ -74,25 +93,25 @@ export class TestWatcher extends Disposable { } })(); - this.vitestState = buildWatchClient({ - handlers: { - onCollected: this.onCollected, - onTaskUpdate: () => { - console.log("update"); - if (!run) { - this.run = this.ctrl.createTestRun(new TestRunRequest()); - } - }, - onFinished: () => { - console.log("finished"); - if (!this.run) { - return; - } + setTimeout(() => { + this.vitestState = buildWatchClient({ + handlers: { + onFinished: (files) => { + console.log("finished"); + this.onFinished(files); + if (!this.run) { + return; + } - this.run.end(); + this.run.end(); + this.run = undefined; + }, }, - }, - }); + }); + effect(() => { + this.onFileUpdated(this.vitestState!.files.value); + }); + }, 5000); } public runTests(tests?: readonly TestItem[]) { @@ -105,6 +124,14 @@ export class TestWatcher extends Disposable { this.runFiles(files); return; } + + this.runFiles( + this.vitestState.files.value.filter((file) => + tests.some((test) => + WEAKMAP_TEST_DATA.get(test)!.getFilePath().includes(file.filepath) + ) + ), + ); } private runFiles(files: File[]) { @@ -112,6 +139,18 @@ export class TestWatcher extends Disposable { return; } + if (!this.run) { + this.run = this.ctrl.createTestRun(new TestRunRequest()); + for (const file of files) { + const data = this.discover.discoverTestFromPath( + this.ctrl, + file.filepath, + ); + + this.run.enqueued(data.item); + } + } + files.forEach((f) => { delete f.result; getTasks(f).forEach((i) => delete i.result); @@ -121,32 +160,44 @@ export class TestWatcher extends Disposable { return client.rpc.rerun(files.map((i) => i.filepath)); } - private readonly onCollected = (files?: File[]) => { - console.log("on collect", files); + private readonly onFileUpdated = (files?: File[]) => { if (files == undefined) { this.discover.discoverAllFilesInWorkspace(this.ctrl); } else { for (const file of files) { - const data = this.discover.discoverTestFromPath( + this.discover.discoverTestFromPath( this.ctrl, file.filepath, ); - this.attach(data, file); } } }; + private readonly onFinished = (files?: File[]) => { + if (!files) { + return; + } + if (!this.run) { + this.run = this.ctrl.createTestRun(new TestRunRequest()); + } + + for (const file of files) { + const data = this.discover.discoverTestFromPath( + this.ctrl, + file.filepath, + ); + + this.attach(data, file); + } + }; + private attach(vscodeFile: TestFile, vitestFile: File) { - effect(() => { - const run = this.run; - if (!run) { - console.log("no run"); - return; - } + const run = this.run; + if (!run) { + return; + } - console.log("running effect for", vitestFile.filepath); - attach(run, vscodeFile.children, vitestFile.tasks); - }); + attach(run, vscodeFile.children, vitestFile.tasks); function attach( run: TestRun, diff --git a/yarn.lock b/yarn.lock index fa8bd9dd..b5f2499b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -124,11 +124,6 @@ resolved "https://registry.npmmirror.com/@types/minimatch/-/minimatch-3.0.5.tgz" integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== -"@types/mocha@^9.1.0": - version "9.1.0" - resolved "https://registry.npmmirror.com/@types/mocha/-/mocha-9.1.0.tgz" - integrity sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg== - "@types/node@*": version "17.0.21" resolved "https://registry.npmmirror.com/@types/node/-/node-17.0.21.tgz"