We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ffbc05a commit 90451a6Copy full SHA for 90451a6
test/parallel/test-repl-eval.js
@@ -0,0 +1,29 @@
1
+'use strict';
2
+const common = require('../common');
3
+const assert = require('assert');
4
+const repl = require('repl');
5
+
6
+{
7
+ let evalCalledWithExpectedArgs = false;
8
9
+ const options = {
10
+ eval: common.mustCall((cmd, context) => {
11
+ // Assertions here will not cause the test to exit with an error code
12
+ // so set a boolean that is checked in process.on('exit',...) instead.
13
+ evalCalledWithExpectedArgs = (cmd === 'foo\n' && context.foo === 'bar');
14
+ })
15
+ };
16
17
+ const r = repl.start(options);
18
+ r.context = {foo: 'bar'};
19
20
+ try {
21
+ r.write('foo\n');
22
+ } finally {
23
+ r.write('.exit\n');
24
+ }
25
26
+ process.on('exit', () => {
27
+ assert(evalCalledWithExpectedArgs);
28
+ });
29
+}
0 commit comments