Add an ES6-friendly way to register "should"
See original GitHub issueI suggest adding a file named should.js
at the root of this project that auto-registers ‘should’, i.e. require('./index').should();
.
/* CURRENT SITUATION */
// commonjs style looks nice
require('chai').should();
// but es6 isn't so nice
import chai from 'chai';
chai.should();
// or you can do this, but it's still 2 lines
import {should} from 'chai';
should();
/* PROPOSAL */
// single-line way to register 'should' in ES6
import `chai/should`;
// nb. other libraries use this convention too
import 'babel-core/register';
import 'coffee-script/register';
Note: people sometimes think side-effecting imports feel dirty, but it’s arguably less dirty than a globally side-effecting function call like .should()
. When you have a ‘fromless’ import that doesn’t assign any variables, the syntax is explicitly intended for side-effects.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to Use ES6 Features in React - freeCodeCamp
So to help you learn these handy features, I'll introduce you to them and then show you how to apply them in React.js....
Read more >Setting up an ES6 Project Using Babel and webpack - SitePoint
Chris Perry shows how to set up a build system for modern JavaScript, using Babel, ES6 modules and webpack, with watch tasks and...
Read more >Adding object properties conditionally with EcmaScript 6 (ES6)
Adding a property to an object is quite easy in JavaScript. You can basically do it like in the following code. 1. const...
Read more >How to enable ES6 Support in Client Scripts (Any version)
Step 2: Write ES6 Client Scripts. Now you can go to any Client Script and start scripting in ES6, ES7, or any new...
Read more >How can I use an ES6 import in Node.js? [duplicate]
Add { "type": "module" } in the nearest package.json . You only need to do one of the above to be able to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After combing the pr’s I found this and it worked.
Maybe the documentation needs to be updated later.
@jonaswindey this should be released as part of
4.0.0
, which will be out soon 😄