testblocks 0.4.0 → 0.6.0

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.
package/dist/cli/index.js CHANGED
@@ -230,7 +230,7 @@ program
230
230
  'test:junit': 'testblocks run tests/**/*.testblocks.json -r junit -o reports',
231
231
  },
232
232
  devDependencies: {
233
- testblocks: '^0.4.0',
233
+ testblocks: '^0.6.0',
234
234
  },
235
235
  };
236
236
  fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
@@ -54,7 +54,20 @@ exports.getServerPlugins = getServerPlugins;
54
54
  exports.isPluginLoaded = isPluginLoaded;
55
55
  const fs = __importStar(require("fs"));
56
56
  const path = __importStar(require("path"));
57
+ const jiti_1 = require("jiti");
57
58
  const core_1 = require("../core");
59
+ // Create jiti instance for loading TypeScript plugins at runtime
60
+ // Configure it to resolve modules from the user's working directory
61
+ const jiti = (0, jiti_1.createJiti)(__filename, {
62
+ interopDefault: true,
63
+ moduleCache: false,
64
+ alias: {
65
+ // Allow plugins to import from 'testblocks' even if they use old relative paths
66
+ '../../src/core': path.join(__dirname, '..', 'core'),
67
+ '../src/core': path.join(__dirname, '..', 'core'),
68
+ './src/core': path.join(__dirname, '..', 'core'),
69
+ },
70
+ });
58
71
  // Track initialization
59
72
  let pluginsInitialized = false;
60
73
  // List of registered plugins
@@ -135,12 +148,13 @@ async function loadPlugin(pluginName) {
135
148
  const jsPath = path.join(pluginsDirectory, `${pluginName}.js`);
136
149
  const tsPath = path.join(pluginsDirectory, `${pluginName}.ts`);
137
150
  let pluginPath = null;
151
+ let isTypeScript = false;
138
152
  if (fs.existsSync(jsPath)) {
139
153
  pluginPath = jsPath;
140
154
  }
141
155
  else if (fs.existsSync(tsPath)) {
142
- // For TypeScript files, require ts-node or esbuild-register
143
156
  pluginPath = tsPath;
157
+ isTypeScript = true;
144
158
  }
145
159
  if (!pluginPath) {
146
160
  console.error(`Plugin not found: ${pluginName} (looked in ${pluginsDirectory})`);
@@ -148,8 +162,14 @@ async function loadPlugin(pluginName) {
148
162
  }
149
163
  try {
150
164
  console.log(`Loading plugin: ${pluginName} from ${pluginPath}`);
151
- // Dynamic import
152
- const module = await Promise.resolve(`${pluginPath}`).then(s => __importStar(require(s)));
165
+ // Use jiti for TypeScript files, dynamic import for JavaScript
166
+ let module;
167
+ if (isTypeScript) {
168
+ module = jiti(pluginPath);
169
+ }
170
+ else {
171
+ module = await Promise.resolve(`${pluginPath}`).then(s => __importStar(require(s)));
172
+ }
153
173
  // Look for default export or named export matching plugin name
154
174
  const plugin = module.default ||
155
175
  module[pluginName.replace(/-./g, x => x[1].toUpperCase()) + 'Plugin'] ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testblocks",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Visual test automation tool with Blockly - API and Playwright testing",
5
5
  "author": "Roy de Kleijn",
6
6
  "license": "MIT",
@@ -70,6 +70,7 @@
70
70
  "cors": "^2.8.5",
71
71
  "express": "^4.21.2",
72
72
  "glob": "^11.0.0",
73
+ "jiti": "^2.6.1",
73
74
  "jsonpath-plus": "^10.3.0",
74
75
  "otpauth": "^9.4.1",
75
76
  "playwright": "^1.49.1",
@@ -79,7 +80,6 @@
79
80
  "xpath": "^0.0.34"
80
81
  },
81
82
  "devDependencies": {
82
- "@vitest/coverage-v8": "^2.1.8",
83
83
  "@eslint/js": "^9.39.2",
84
84
  "@types/cors": "^2.8.17",
85
85
  "@types/express": "^5.0.0",
@@ -90,6 +90,7 @@
90
90
  "@typescript-eslint/eslint-plugin": "^8.51.0",
91
91
  "@typescript-eslint/parser": "^8.51.0",
92
92
  "@vitejs/plugin-react": "^4.3.4",
93
+ "@vitest/coverage-v8": "^2.1.8",
93
94
  "concurrently": "^8.2.2",
94
95
  "eslint": "^9.39.2",
95
96
  "eslint-plugin-react": "^7.37.5",