@juliendu11/japa-ui-reporter 0.0.1 → 0.0.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.
- package/README.MD +3 -1
- package/build/ui/server.js +2 -2
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://npmjs.org/package/@juliendu11/japa-ui-reporter)
|
|
2
|
+
|
|
1
3
|
# Japa UI reporter
|
|
2
4
|
|
|
3
5
|
Frustrated by the various default reporting tools, I created my own.
|
|
@@ -47,4 +49,4 @@ UIReporter.ui({
|
|
|
47
49
|
## How it works
|
|
48
50
|
|
|
49
51
|
The reporter starts a server that serves the dashboard and listens for test events. When a test event occurs, it sends
|
|
50
|
-
the data to the dashboard via WebSocket, which updates the UI accordingly.
|
|
52
|
+
the data to the dashboard via WebSocket, which updates the UI accordingly.
|
package/build/ui/server.js
CHANGED
|
@@ -2,14 +2,14 @@ import http from "node:http";
|
|
|
2
2
|
import net from "node:net";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
5
6
|
import { WebSocketServer } from "ws";
|
|
6
|
-
const __dirname = path.dirname(
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
8
|
export default function createServer(options) {
|
|
8
9
|
// Connected dashboard clients
|
|
9
10
|
const dashboardClients = new Set();
|
|
10
11
|
// HTTP server to serve the dashboard
|
|
11
12
|
const httpServer = http.createServer((req, res) => {
|
|
12
|
-
console.log(req.url);
|
|
13
13
|
if (req.url === '/' || req.url === '/index.html') {
|
|
14
14
|
const filePath = path.join(__dirname, 'public', 'index.html');
|
|
15
15
|
fs.readFile(filePath, (err, data) => {
|