Skip to content

Instantly share code, notes, and snippets.

const dotenv = await fs.readFile('.env');
dotenv
.toString('utf-8')
.split('\n')
.map(line => line.replace(/#.*$/, ''))
.map(line => line.trim())
.filter(line => line.match(/\S/))
.map(line => line.split('='))
.forEach(([key, value]) => key in process.env || (process.env[key] = value));
import * as GLOBALS from './globals.js';
const DEFAULTS = { ...GLOBALS };
export class Config {
static get defaults () { return DEFAULTS }
static get globals () { return GLOBALS }
constructor (values) {
this.values = { ...Config.defaults };
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<div id="log"></div>
<button id="button">Click me</button>
<script>
function create (handler) {
  1. Выразительный JavaScript (Eloquent JavaScript) - Хавербеке Марейн (Haverbeke Marjin)
  2. https://developer.mozilla.org/ru/docs/Web/JavaScript
  3. Airbnb Javascript Style Guide
  4. Node.js documentation
  5. TypeScript Handbook
  6. Экстремальное программирование: планирование - Кент Бек, Мартин Фаулер
  7. Рефакторинг: улучшение существующего кода - Мартин Фаулер
  8. Программист‑прагматик - Дейв Томас, Энди Хант
  9. The Passionate Programmer - Чед Фаулер (перевод главы на Хабре)
  10. The Twelve-Factor App
@AndreyBelym
AndreyBelym / runner.js
Created September 25, 2019 08:35
Passing parameters to TestCafe tests
const createTestCafe = require('testcafe');
(async => {
process.env.params = JSON.stringify({
'test1': {
'foo': 'bar'
},
'test2': {
'foo': 'foobar'
}
@AndreyBelym
AndreyBelym / cookies-test.js
Created June 7, 2019 16:04
Accessing cookies in a TestCafe test with RequestLogger
import { RequestLogger } from 'testcafe';
fixture `Cookies`.page`example.com`;
test('Log cookies', async t => {
const logger = RequestLogger('http://example.com');
await t.addRequestHooks(logger);
// Do your test actions...

import { ClientFunction } from "testcafe";

fixtureChange.org;

const changeUserState = ClientFunction((desiredState) => { const initialState = App.get('currentUser').get('login_state');

App.get('currentUser').set('login_state', desiredState);

const longRunningPostRequest = require('./setup/seed-database');
const createTestCafe = require('testcafe');
const RUN_OPTIONS = {pageLoadTimeout: 120000, selectorTimeout: 15000};
const setupLicense = async () => {
const testcafe = await createTestCafe('localhost', 1337, 1338, undefined, true);
const runner = testcafe.createRunner();
const failedCount = await runner
.src(['fixtures/setup-license.js'])

CLI

    --video-recording <path-to-file-or-folder>
    --video-recording-options <option>=<value>[,<option2>=<value2>,...]
Option Type Description
mode Enum all-tests-at-once, test-by-test, only-failed
module ns %
babel-core 2415741000 25%
testcafe-hammerhead 2893672578 30%
testcafe-browser-tools 977508426 10%
client-functions\selectors\selector-builder\add-api (babel-plugin-*) 1875468857 20%
total 9541507872 100%