How to use the testcafe.t.eval function in testcafe

To help you get started, we’ve selected a few testcafe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gridgain / gridgain / modules / web-console / e2e / testcafe / roles.js View on Github external
return Role(resolveUrl('/signin'), async() => {
        await t.eval(() => window.localStorage.clear());

        // Disable "Getting started" modal.
        await t.eval(() => window.localStorage.showGettingStarted = 'false');
        await page.login(login, password);
    });
};
github TheBrainFamily / TheBrain2.0 / testing / testHelpers / startAppTestCafe.js View on Github external
const startAppTestCafe = async (path, typeDefs, resolvers) => {
  const stringifiedResolvers = stringify(resolvers)
  await t.eval(() => {
    if (window.__APOLLO_CLIENT__) {
      const parsedResolvers = window.__APOLLO_TEST_TOOLS.parse(stringifiedResolvers)

      const schema = window.__APOLLO_TEST_TOOLS.makeExecutableSchema({typeDefs, resolvers: parsedResolvers, resolverValidationOptions: {allowResolversNotInSchema: true}})
      window.__APOLLO_TEST_TOOLS.addMockFunctionsToSchema({schema, preserveResolvers: true})

      const newNetworkInterface = window.__APOLLO_TEST_TOOLS.mockNetworkInterfaceWithSchema({schema})

      Object.assign(window.__APOLLO_CLIENT__.networkInterface, newNetworkInterface)
    }
  }, {
    dependencies: {stringifiedResolvers, typeDefs}
  })

  return new TestCafeDriver()
}
github frappe / video / lib / desk.js View on Github external
async scroll_to_element(el, text, time = 1) {
		await this.wait_for_ajax();

		time = time * 1000;
		let selector = `${el}:visible`

		if (text) {
			selector += `:contains("${text}")`;
		}

		const value = await t.eval(() => {
			const el = $(selector);
			if(el.length === 0) {
				throw `Could not find element matching ${selector}`
			}
			return el.offset().top - 150;
		}, { dependencies: { selector } });

		await this._scroll(value, time);
	},