Skip to content

Instantly share code, notes, and snippets.

View giltayar's full-sized avatar

Gil Tayar giltayar

View GitHub Profile
import {kettle} from './02-kettle.mjs' //fails with error
console.log(kettle)
const {kettle} = require('./kettle.js') // fails with error
console.log(kettle)
import kettleModule from './kettle.js' // succeeds
console.log(kettleModule.kettle)
{
"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",
{
"plugins": [
"transform-es2015-modules-commonjs", "dynamic-import-node"
]
}
const {kettle} = require('./kettle.mjs') // fails with error
console.log(kettle)
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')
const countItemsLeft = cy.contains('item left')
if (countItemsLeft.innerText === '1 items left') {
// do something...
}
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!')
}
})
'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})