@testsmith/perfornium 0.5.0 → 0.6.1

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.
@@ -278,9 +278,11 @@ class DashboardServer {
278
278
  async handleRunTest(req, res) {
279
279
  const body = await this.readBody(req);
280
280
  const { testPath, options } = JSON.parse(body);
281
+ // Normalize the test path to use native separators for the OS
282
+ const normalizedTestPath = path.normalize(testPath);
281
283
  const testId = `run-${Date.now()}`;
282
- const testName = path.basename(testPath).replace(/\.(yml|yaml|json)$/, '');
283
- const args = ['run', testPath];
284
+ const testName = path.basename(normalizedTestPath).replace(/\.(yml|yaml|json)$/, '');
285
+ const args = ['run', normalizedTestPath];
284
286
  if (options?.verbose)
285
287
  args.push('-v');
286
288
  if (options?.report)
@@ -574,18 +576,21 @@ class DashboardServer {
574
576
  }
575
577
  const stat = await fs.stat(fullPath);
576
578
  const relativePath = path.relative(baseDir, fullPath);
577
- // Detect test type from content or path
579
+ // Detect test type from content or path (use forward slashes for cross-platform matching)
580
+ const normalizedPath = fullPath.replace(/\\/g, '/');
578
581
  let testType = 'api';
579
- if (content.includes('protocol: web') || content.includes('playwright') || fullPath.includes('/web/')) {
582
+ if (content.includes('protocol: web') || content.includes('playwright') || normalizedPath.includes('/web/')) {
580
583
  testType = 'web';
581
584
  }
582
- else if (content.includes('protocol: http') || content.includes('protocol: https') || fullPath.includes('/api/')) {
585
+ else if (content.includes('protocol: http') || content.includes('protocol: https') || normalizedPath.includes('/api/')) {
583
586
  testType = 'api';
584
587
  }
588
+ // Normalize paths to forward slashes for cross-platform compatibility
589
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
585
590
  tests.push({
586
591
  name: entry.name.replace(/\.(yml|yaml|json)$/, ''),
587
- path: fullPath,
588
- relativePath,
592
+ path: fullPath, // Keep native path for filesystem operations
593
+ relativePath: normalizedRelativePath, // Use forward slashes for display/URLs
589
594
  type: testType,
590
595
  lastModified: stat.mtime.toISOString()
591
596
  });
@@ -1092,18 +1097,24 @@ class DashboardServer {
1092
1097
  container.innerHTML = '<div class="empty-state"><h3>No tests found</h3><p>Add test files to your tests/ folder</p></div>';
1093
1098
  return;
1094
1099
  }
1095
- container.innerHTML = testFiles.map(t => \`
1100
+ container.innerHTML = testFiles.map((t, idx) => \`
1096
1101
  <div class="test-item">
1097
1102
  <div class="test-info">
1098
1103
  <div class="test-name">\${t.name}</div>
1099
1104
  <div class="test-path">\${t.relativePath}</div>
1100
1105
  </div>
1101
1106
  <span class="test-type \${t.type}">\${t.type}</span>
1102
- <button class="btn btn-primary btn-sm" style="margin-left: 12px;" onclick="runTest('\${t.path}')" \${runningTestId ? 'disabled' : ''}>Run</button>
1107
+ <button class="btn btn-primary btn-sm" style="margin-left: 12px;" onclick="runTestByIndex(\${idx})" \${runningTestId ? 'disabled' : ''}>Run</button>
1103
1108
  </div>
1104
1109
  \`).join('');
1105
1110
  }
1106
1111
 
1112
+ function runTestByIndex(idx) {
1113
+ if (idx >= 0 && idx < testFiles.length) {
1114
+ runTest(testFiles[idx].path);
1115
+ }
1116
+ }
1117
+
1107
1118
  async function runTest(testPath) {
1108
1119
  if (runningTestId) return;
1109
1120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testsmith/perfornium",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Flexible performance testing framework for REST, SOAP, and web applications",
5
5
  "author": "TestSmith",
6
6
  "license": "MIT",