Skip to content

Instantly share code, notes, and snippets.

Gil Tayar giltayar

Block or report user

Report or block giltayar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View computeIntensiveRunner.js
const {promisify} = require('util')
const crypto = require('crypto')
function randomString() {
return crypto.randomBytes(100).toString('hex');
}
function* computeIntensiveCode() {
const hash = crypto.createHash('sha256');
for (let i=0; i < 100; i++) {
View cypress-example.js
'use strict'
describe(`TodoMVC using Cypress`, function () {
it('can add todos and then delete them', () => {
cy.visit('http://todomvc.com/examples/react/#/')
cy.get('.new-todo').type('Cook dinner{enter}')
cy.get('.view > label').should('have.text', 'Cook dinner')
cy.get('.new-todo').type('Clean house{enter}').then(() => {debugger})
View cypress-good-conditional-code.js
cy.contains('item left')
// do the following code on the element that contains "item left".
.then(countItemsLeft => {
// if the text in the element is "1 items left", log it.
if (countItemsLeft.innerText === '1 items left') {
console.log('lalala!')
}
})
View cypress-bad-conditional-code.js
const countItemsLeft = cy.contains('item left')
if (countItemsLeft.innerText === '1 items left') {
// do something...
}
View cypress-todomvc-example_spec.js
describe(`TodoMVC using Cypress`, function () {
it('can add todos and then delete them', () => {
// visit the todomvc application
cy.visit('http://todomvc.com/examples/react/#/')
// type a new todo into the "new todo" input field.
cy.get('.new-todo').type('Cook dinner{enter}')
// ensure that a new todo was created correctly
cy.get('.view > label').should('have.text', 'Cook dinner')
View main(CJS).js
const {kettle} = require('./kettle.mjs') // fails with error
console.log(kettle)
View .babelrc
{
"plugins": [
"transform-es2015-modules-commonjs", "dynamic-import-node"
]
}
View esm-dual-mode-package.json
{
"name": "dual-cjs-mjs-package",
"version": "1.0.0",
"description": "A package that can be both imported as esm and as cjs",
"main": "entry",
"scripts": {
"build": "babel *.mjs **/*.mjs --out-dir ."
},
"devDependencies": {
"babel-cli": "^6.26.0",
View main(ESM)-2.mjs
import kettleModule from './kettle.js' // succeeds
console.log(kettleModule.kettle)
View main(ESM).mjs
const {kettle} = require('./kettle.js') // fails with error
console.log(kettle)
You can’t perform that action at this time.