diff --git a/README.md b/README.md index 621dc2554..52533a6d8 100644 --- a/README.md +++ b/README.md @@ -567,7 +567,7 @@ it('test1', async ({ browser }) => { ``` #### Execution context -The execution context can be accessed by the `browser.executionContext` property, which contains the current test/hook mocha object extended with the browser id. +The execution context can be accessed by the `browser.executionContext` property, which contains the current test/hook object extended with the browser id. Example: ```js diff --git a/src/browser/commands/assert-view/index.js b/src/browser/commands/assert-view/index.js index 8dc5f1107..411014f8e 100644 --- a/src/browser/commands/assert-view/index.js +++ b/src/browser/commands/assert-view/index.js @@ -8,7 +8,6 @@ const Image = require("../../../image"); const ScreenShooter = require("../../screen-shooter"); const temp = require("../../../temp"); const { getCaptureProcessors } = require("./capture-processors"); -const { getTestContext } = require("../../../utils/mocha"); const RuntimeConfig = require("../../../config/runtime-config"); const AssertViewResults = require("./assert-view-results"); const BaseStateError = require("./errors/base-state-error"); @@ -60,7 +59,7 @@ module.exports = browser => { const currSize = await currImgInst.getSize(); const currImg = { path: temp.path(Object.assign(tempOpts, { suffix: ".png" })), size: currSize }; - const test = getTestContext(session.executionContext); + const test = session.executionContext.ctx.currentTest; const refImg = { path: config.getScreenshotPath(test, state), size: null }; const { emitter } = browser; diff --git a/src/utils/mocha.js b/src/utils/mocha.js deleted file mode 100644 index 51d7547b2..000000000 --- a/src/utils/mocha.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -exports.getTestContext = context => { - return context.type === "hook" && /^"before each"/.test(context.title) ? context.ctx.currentTest : context; -}; diff --git a/test/src/browser/commands/assert-view/index.js b/test/src/browser/commands/assert-view/index.js index 932e08ded..79de6eefb 100644 --- a/test/src/browser/commands/assert-view/index.js +++ b/test/src/browser/commands/assert-view/index.js @@ -66,7 +66,7 @@ describe("assertView command", () => { }; const initBrowser_ = ({ browser = stubBrowser_(), session = mkSessionStub_() } = {}) => { - session.executionContext = { hermioneCtx: {} }; + session.executionContext = { hermioneCtx: {}, ctx: {} }; sandbox.stub(webdriverio, "attach").resolves(session); return browser.init({ sessionId: session.sessionId, sessionCaps: session.capabilities });