@eggjs/tegg-vitest 4.0.2-beta.1 → 4.0.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/runner.js +21 -22
  2. package/package.json +4 -4
package/dist/runner.js CHANGED
@@ -55,28 +55,27 @@ var TeggVitestRunner = class extends VitestTestRunner {
55
55
  const result = await super.importFile(filepath, source);
56
56
  if (source === "collect") {
57
57
  const rawConfig = globalThis.__teggVitestConfig;
58
- if (rawConfig) {
59
- delete globalThis.__teggVitestConfig;
60
- const config = {
61
- restoreMocks: rawConfig.restoreMocks ?? true,
62
- getApp: rawConfig.getApp ?? defaultGetApp
63
- };
64
- debugLog(`captured config for ${filepath}`);
65
- try {
66
- const app = await config.getApp();
67
- if (app) {
68
- await app.ready();
69
- this.fileAppMap.set(filepath, {
70
- app,
71
- config
72
- });
73
- debugLog(`app ready for ${filepath}`);
74
- }
75
- } catch (err) {
76
- if (!this.warned) {
77
- this.warned = true;
78
- console.warn("[tegg-vitest] getApp failed, skip context injection.", err);
79
- }
58
+ delete globalThis.__teggVitestConfig;
59
+ const config = {
60
+ restoreMocks: rawConfig?.restoreMocks ?? true,
61
+ getApp: rawConfig?.getApp ?? defaultGetApp
62
+ };
63
+ if (rawConfig) debugLog(`captured config for ${filepath}`);
64
+ else debugLog(`auto-detect app for ${filepath}`);
65
+ if (!this.fileAppMap.has(filepath)) try {
66
+ const app = await config.getApp();
67
+ if (app) {
68
+ await app.ready();
69
+ this.fileAppMap.set(filepath, {
70
+ app,
71
+ config
72
+ });
73
+ debugLog(`app ready for ${filepath}`);
74
+ }
75
+ } catch {
76
+ if (!this.warned) {
77
+ this.warned = true;
78
+ debugLog("getApp failed, skip context injection.");
80
79
  }
81
80
  }
82
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/tegg-vitest",
3
- "version": "4.0.2-beta.1",
3
+ "version": "4.0.2-beta.2",
4
4
  "description": "Vitest adapter for tegg context injection",
5
5
  "keywords": [
6
6
  "adapter",
@@ -37,15 +37,15 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@eggjs/mock": "7.0.2-beta.1"
40
+ "@eggjs/mock": "7.0.2-beta.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^24.10.2",
44
44
  "tsx": "4.20.6",
45
45
  "typescript": "^5.9.3",
46
46
  "vitest": "^4.0.15",
47
- "@eggjs/core-decorator": "4.0.2-beta.1",
48
- "egg": "4.1.2-beta.1"
47
+ "egg": "4.1.2-beta.2",
48
+ "@eggjs/core-decorator": "4.0.2-beta.2"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "vitest": "^4.0.15"