testdriverai 4.2.29 → 4.2.31
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/CONTRIBUTING.md +45 -0
- package/README.md +1 -0
- package/lib/logger.js +7 -9
- package/package.json +1 -1
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Setup `testdriverai` repo
|
|
4
|
+
|
|
5
|
+
1. `gh repo clone testdriverai/testdriverai`
|
|
6
|
+
1. `npm install` project dependencies
|
|
7
|
+
1. `npm link`
|
|
8
|
+
|
|
9
|
+
## Setting up a Test Project
|
|
10
|
+
|
|
11
|
+
1. `cd $(mktemp -d)` to create a blank project
|
|
12
|
+
1. `npm link testdriverai`
|
|
13
|
+
1. `npx testdriverai init`
|
|
14
|
+
|
|
15
|
+
> Spawning GUI...
|
|
16
|
+
> Howdy! I'm TestDriver v4.2.29
|
|
17
|
+
> Working on **/private/var/folders/4w/\_l20wtfj41n2dx0xyhb8xd740000gn/T/tmp.PDxTlOLJBS/testdriver/testdriver.yml**
|
|
18
|
+
> ...
|
|
19
|
+
|
|
20
|
+
1. `npx testdriverai testdriver/test.yml`
|
|
21
|
+
|
|
22
|
+
## Testing against local `api`
|
|
23
|
+
|
|
24
|
+
When running [replayableio/api](https://github.com/replayableio/api/) locally, specify `TD_API_ROOT` in your `.env` file or shell:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
TD_API_ROOT=http://localhost:1337 npx testdriverai
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Logging
|
|
31
|
+
|
|
32
|
+
- `DEV` to log the config
|
|
33
|
+
- `VERBOSE` to log `logger.debug` (Default: `logger.info` and above)
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
DEV=true VERBOSE=true npx testdriverai
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Debugging with Chrome Node Inspector
|
|
40
|
+
|
|
41
|
+
> https://nodejs.org/en/learn/getting-started/debugging
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npx --node-options=--inspect testdriverai init
|
|
45
|
+
```
|
package/README.md
CHANGED
package/lib/logger.js
CHANGED
|
@@ -16,35 +16,35 @@ const logFormat = printf(({ message }) => {
|
|
|
16
16
|
return `${message}`;
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
let interpolationVars = JSON.parse(process.env.TD_INTERPOLATION_VARS ||
|
|
19
|
+
let interpolationVars = JSON.parse(process.env.TD_INTERPOLATION_VARS || "{}");
|
|
20
20
|
|
|
21
21
|
const censorSensitiveData = (message) => {
|
|
22
22
|
for (let value of Object.values(interpolationVars)) {
|
|
23
|
-
|
|
24
23
|
// Avoid replacing vars that are 0 or 1 character
|
|
25
24
|
if (value.length >= 2) {
|
|
26
25
|
message = message.replaceAll(value, "****");
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
return message;
|
|
30
|
-
}
|
|
29
|
+
};
|
|
31
30
|
|
|
32
31
|
const logger = winston.createLogger({
|
|
33
|
-
level: shouldLog ?
|
|
32
|
+
level: shouldLog ? "debug" : "info",
|
|
34
33
|
format: winston.format.combine(
|
|
35
34
|
winston.format.splat(),
|
|
36
35
|
winston.format((info) => {
|
|
37
36
|
info.message = censorSensitiveData(info.message);
|
|
38
37
|
return info;
|
|
39
38
|
})(),
|
|
40
|
-
logFormat
|
|
39
|
+
logFormat,
|
|
41
40
|
),
|
|
42
41
|
transports: [
|
|
43
|
-
new winston.transports.Console(
|
|
42
|
+
new winston.transports.Console({
|
|
43
|
+
forceConsole: true,
|
|
44
|
+
}),
|
|
44
45
|
],
|
|
45
46
|
});
|
|
46
47
|
|
|
47
|
-
|
|
48
48
|
// marked is a markdown parser
|
|
49
49
|
// markedTerminal allows us to render markdown in CLI
|
|
50
50
|
marked.use(
|
|
@@ -89,7 +89,6 @@ const createMarkdownStreamLogger = () => {
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
end() {
|
|
92
|
-
|
|
93
92
|
const previousConsoleOutput = markedParsePartial(buffer, 0, -1);
|
|
94
93
|
const consoleOutput = markedParsePartial(buffer, 0, Infinity);
|
|
95
94
|
let diff = consoleOutput.replace(previousConsoleOutput, "");
|
|
@@ -125,4 +124,3 @@ module.exports = {
|
|
|
125
124
|
prettyMarkdown,
|
|
126
125
|
createMarkdownStreamLogger,
|
|
127
126
|
};
|
|
128
|
-
|