Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix REPL #421

Open
wants to merge 2 commits into
base: v2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions lib/testLauncher/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ function setupRepl(opts, isTTY) {

Object.assign(replInstance.context, vars);

setReplCwd(replInstance, cwd);

return new Promise(resolve => {
replInstance.on('exit', () => {
watcher.close();
Expand Down Expand Up @@ -147,17 +145,6 @@ async function onFileChange(file, cwd, callFile, repeater) {
await func();
}

/**
* Sets the current working directory of the repl shell
* @param {REPLServer} replInstance
* @param {String} cwd - the directory to set
*/
function setReplCwd(replInstance, cwd) {
replInstance.eval('', replInstance.context, __filename, () => {
process.chdir(cwd);
});
}

/**
* Clears node require cache for the file and requires this file again
* @param {string} f - path to the file to re-require
Expand Down
2 changes: 1 addition & 1 deletion test/testLauncher/repl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('repl', () => {
}, false);

await new Promise(resolve => {
setInterval(() => chDir.called && resolve(), 10);
setInterval(() => chDir.notCalled && resolve(), 10);
});

await new Promise(resolve => {
Expand Down
3 changes: 2 additions & 1 deletion testDefinition/definition.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ describe('suitest typescripts declarations tests', () => {
'videoChain', 'playstationVideoChain', 'indexTest',
'runTestChain', 'takeScreenshotChain', 'saveScreenshotChain',
'setScreenOrientation', 'closeAppChain', 'suspendAppChain',
'interactiveChain',
// 'executeBrightScriptChain', 'brightScriptExpressionChain',
].forEach(fileName => {
it(`should compile example ${fileName}`, (done) => {
Expand All @@ -83,7 +84,7 @@ describe('suitest typescripts declarations tests', () => {
// should compile files with error
[
'networkRequestChain.fail', 'elementChain.fail', 'videoChain.fail', 'playstationVideoChain.fail',
'runTestChain.fail',
'runTestChain.fail', 'interactiveChain.fail',
].forEach(fileName => {
it(`should not compile example ${fileName} chain`, (done) => {
assert.ok(
Expand Down
6 changes: 6 additions & 0 deletions testDefinition/examplesTS/interactiveChain.fail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as suitest from '../../index';

const {interactive} = suitest;

const illegalVarsRepl = interactive({vars: "string"});
illegalVarsRepl.then();
19 changes: 19 additions & 0 deletions testDefinition/examplesTS/interactiveChain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as suitest from '../../index';

const {interactive} = suitest;

// should have all necessary modifiers
const baseRepl = interactive({});
baseRepl.then();

// can have empty vars
const emptyVarsRepl = interactive({vars: {}});
emptyVarsRepl.then();

// can have vars with values of different types
const a = "foobar";
const b = 5;
const c = {one: "two"};

const varsRepl = interactive({vars: {a, b, c}});
varsRepl.then();
7 changes: 5 additions & 2 deletions typeDefinition/InteractiveCommandChain.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { REPLServer } from "repl";

export type ReplOptions = {
cwd?:string,
cwd?: string,
repeater?: string|Function,
watch?: string|Array<string>,
ignored?:string
ignored?: string,
vars?: REPLServer["context"],
}