Skip to content

Commit e7b6fe0

Browse files
committed
Added custom timeout and updated readme
1 parent 1a3fcb4 commit e7b6fe0

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ module.exports = {
2424
}
2525
```
2626

27-
## Configuration
28-
The plugin uses an HTTP API service to interact with the OpenAI API. By default a service is provided for demo purposes, which is configured in the `.env` file.
27+
## Configuring the AI Analysis Service
28+
The plugin uses an HTTP API service to interact with the OpenAI API. By default a service is provided for demo purposes, which is configured in the `.env` file in this project.
2929

3030
You can host your own service by cloning the [openai-nightwatch-service](https://github.com/pineviewlabs/openai-nightwatch-service) repository and running it with your own OpenAI API key.
3131

32+
When running the [openai-nightwatch-service](https://github.com/pineviewlabs/openai-nightwatch-service), you need to define the `NIGHTWATCH_ANALYSIS_SERVICE_URL` environment variable to point to the service URL. You can also use `.env` files.
33+
34+
For example, assuming you have the service running at `http://localhost:4001`, you can create a `.env` file with the following content in the root of your Nightwatch project:
35+
36+
```bash
37+
NIGHTWATCH_ANALYSIS_SERVICE_URL=http://localhost:4001/analyze-error
38+
```
39+
3240
## License
3341
MIT

index.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ const dotenv = require('dotenv');
77
const stripAnsi = require('strip-ansi');
88
const stackTraceParser = require('./utils/stackTrace.js');
99

10-
dotenv.config({
11-
path: path.resolve(__dirname, '.env')
12-
});
10+
let SERVICE_URL = process.env.NIGHTWATCH_ANALYSIS_SERVICE_URL;
11+
if (!SERVICE_URL) {
12+
dotenv.config({
13+
path: path.resolve(__dirname, '.env')
14+
});
15+
SERVICE_URL = process.env.SERVICE_URL;
16+
}
17+
1318
marked.use(markedTerminal());
1419

15-
const { SERVICE_URL } = process.env;
1620

1721
/**
1822
* Send an API call to the service with the error message, stack trace,
@@ -88,6 +92,12 @@ function getTestFailures(moduleData) {
8892

8993

9094
module.exports = {
95+
reporterName: 'nightwatch-openai-plugin',
96+
97+
settings: {
98+
timeoutMs: 60000
99+
},
100+
91101
async reporter(results) {
92102

93103
const errors = getErrorMessages(results);

0 commit comments

Comments
 (0)