Skip to content

Instantly share code, notes, and snippets.

const fs = require('fs');
const crypto = require('crypto');
function hashFile (file, algorithm = 'sha512', encoding = 'base64', options) {
return new Promise((resolve, reject) => {
const hash = crypto.createHash(algorithm);
hash.on('error', reject).setEncoding(encoding);
fs.createReadStream(
file,
Object.assign({}, options, {
import { Selector, t } from 'testcafe';
fixture `New Fixture`
.page `http://localhost:3000/`
.beforeEach(async t => {
await t
.typeText('#username', 'Tavares_Barrows')
.typeText('#password', 's3cret')
.click(Selector('main span').withText('SIGN IN'))
});
import { Selector, t } from 'testcafe';
fixture `New Fixture`
.page `http://localhost:3000/`
.beforeEach(async t => {
await t
.typeText('#username', 'Tavares_Barrows')
.typeText('#password', 's3cret')
.click(Selector('main span').withText('SIGN IN'))
});
@helen-dikareva
helen-dikareva / strange_playback_highlinting.js
Created October 8, 2020 12:39
strange_playback_highlinting
import { Selector } from 'testcafe';
fixture`A set of examples that illustrate how to use TestCafe API`
.page`http://devexpress.github.io/testcafe/example/`;
const developerName = Selector('#developer-name');
const triedLabel = Selector('label').withText('I have tried TestCafe');
const sliderHandle = Selector('#slider').child('span');
const submitButton = Selector('#submit-button');
import { RequestMock } from 'testcafe';
const mock = RequestMock()
.onRequestTo((request) => {
return request.url === 'http://localhost:3000/' && request.method === 'get';
})
.respond((req, res) => {
res.statusCode = 200;
res.headers = {
'content-type': 'application/json',
{
"originFile": 123
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button id="button">CLICK ME!</button>
<script>
var express = require('express');
var fs = require('fs');
var app = express();
app.get('/page', function (req, res) {
res.setHeader('content-type', 'text/html');
res.send(fs.readFileSync('./index.html'));
});
app.get('/', function (req, res) {
import {Selector} from 'testcafe';
const label = Selector('label');
class Feature {
label: Selector;
checkbox: Selector;
constructor(text) {
this.label = label.withText(text);
import http from 'http';
const lazyImport = require('import-lazy')(require);
const browserTools = lazyImport('testcafe-browser-tools');
const endpointUtils = lazyImport('endpoint-utils');
const GUID_TITLE = '7cae8e73-44eb-49d8-a275-62a333e6172f';
const WATCH_BROWSER_PAGE = `