Skip to content

Commit fd393d0

Browse files
committed
added indication that a test is executed within another test
1 parent 3fdecee commit fd393d0

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

packages/selenium-ide/src/neo/IO/SideeX/playback.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ function doSeleniumCommand(id, command, target, value, implicitTime, implicitCou
288288
function doPluginCommand(id, command, target, value, implicitTime, implicitCount) {
289289
return executeCommand(command, target, value, {
290290
commandId: id,
291+
isNested: !!PlaybackState.callstack.length,
291292
runId: PlaybackState.runId,
292293
testId: PlaybackState.currentRunningTest.id,
293294
frameId: extCommand.getCurrentPlayingFrameId(),

packages/selianize/__tests__/command.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe("command code emitter", () => {
137137
target: "some test case",
138138
value: ""
139139
};
140-
return expect(CommandEmitter.emit(command)).resolves.toBe("await tests.some_test_case(driver, vars);");
140+
return expect(CommandEmitter.emit(command)).resolves.toBe("await tests.some_test_case(driver, vars, { isNested: true });");
141141
});
142142
it("should emit `run script` command", () => {
143143
const command = {

packages/selianize/__tests__/testcase.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("test case code emitter", () => {
2727
return expect(TestCaseEmitter.emit(test)).resolves.toEqual({
2828
name: "example test case",
2929
test: `it("${test.name}", async () => {await tests.example_test_case(driver, vars);await driver.getTitle().then(title => {expect(title).toBeDefined();});});`,
30-
function: "tests.example_test_case = async function example_test_case(driver, vars) {}"
30+
function: "tests.example_test_case = async function example_test_case(driver, vars, opts) {}"
3131
});
3232
});
3333
it("should emit a test with a single command", () => {
@@ -43,7 +43,7 @@ describe("test case code emitter", () => {
4343
return expect(TestCaseEmitter.emit(test)).resolves.toEqual({
4444
name: "example test case",
4545
test: `it("${test.name}", async () => {await tests.example_test_case(driver, vars);await driver.getTitle().then(title => {expect(title).toBeDefined();});});`,
46-
function: `tests.example_test_case = async function example_test_case(driver, vars) {await driver.get(BASE_URL + "${test.commands[0].target}");}`
46+
function: `tests.example_test_case = async function example_test_case(driver, vars, opts) {await driver.get(BASE_URL + "${test.commands[0].target}");}`
4747
});
4848
});
4949
it("should emit a test with multiple commands", () => {
@@ -71,7 +71,7 @@ describe("test case code emitter", () => {
7171
return expect(TestCaseEmitter.emit(test)).resolves.toEqual({
7272
name: "example test case",
7373
test: `it("${test.name}", async () => {await tests.example_test_case(driver, vars);await driver.getTitle().then(title => {expect(title).toBeDefined();});});`,
74-
function: `tests.example_test_case = async function example_test_case(driver, vars) {await driver.get(BASE_URL + "${test.commands[0].target}");await driver.get(BASE_URL + "${test.commands[1].target}");await driver.get(BASE_URL + "${test.commands[2].target}");}`
74+
function: `tests.example_test_case = async function example_test_case(driver, vars, opts) {await driver.get(BASE_URL + "${test.commands[0].target}");await driver.get(BASE_URL + "${test.commands[1].target}");await driver.get(BASE_URL + "${test.commands[2].target}");}`
7575
});
7676
});
7777
it("should reject a test with failed commands", () => {
@@ -133,7 +133,7 @@ describe("test case code emitter", () => {
133133
return expect(TestCaseEmitter.emit(test, { silenceErrors: true })).resolves.toEqual({
134134
name: "silence",
135135
test: "it(\"silence\", async () => {await tests.silence(driver, vars);await driver.getTitle().then(title => {expect(title).toBeDefined();});});",
136-
function: "tests.silence = async function silence(driver, vars) {throw new Error(\"Unknown command doesntExist\");}"
136+
function: "tests.silence = async function silence(driver, vars, opts) {throw new Error(\"Unknown command doesntExist\");}"
137137
});
138138
});
139139
});

packages/selianize/src/command.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ async function emitUncheck(locator) {
173173
}
174174

175175
async function emitRun(testCase) {
176-
return Promise.resolve(`await tests.${convertToSnake(testCase)}(driver, vars);`);
176+
return Promise.resolve(`await tests.${convertToSnake(testCase)}(driver, vars, { isNested: true });`);
177177
}
178178

179179
async function emitRunScript(script) {

packages/selianize/src/testcase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function emit(test, options = config) {
3333
emittedTest += hookResults.map((hook) => hook.teardown || "").join("");
3434
emittedTest += "});";
3535

36-
let func = `tests.${testName} = async function ${testName}(driver, vars) {`;
36+
let func = `tests.${testName} = async function ${testName}(driver, vars, opts) {`;
3737
let errors = [];
3838
func += (await Promise.all(test.commands.map((command, index) => (CommandEmitter.emit(command).catch(e => {
3939
if (options.silenceErrors) {

0 commit comments

Comments
 (0)