Is there a shorter ES6 way of doing:
var assert = require('chai').assert;
than
import chai from 'chai';
var assert = chai.assert;
(chai is the chai-assertion library, in case you haven't heard of it yet.)
Is there a shorter ES6 way of doing:
var assert = require('chai').assert;
than
import chai from 'chai';
var assert = chai.assert;
(chai is the chai-assertion library, in case you haven't heard of it yet.)
Yes, you can do it like:
import { assert } from 'chai';
assert
must be exporting from chai
in that case. See spec here and about es6 modules here
assert
like that. This answer will NOT work for chai (at least not in version 8). –
Spring You can use it like this:
import * as chai from 'chai';
let assert = chai.assert;
let should = chai.should();
let expect = chai.expect;
I'd rather:
import {assert, should, expect} from 'chai';
should
: chaijs.com/guide/styles/#using-should-in-es2015 With your solution you'll have to use should().not.equal
instead of should.not.equal
–
Gnosis should('value1').not.be.equal('value2)
–
Linebreeding expect('someValue').to.be.ok
–
Linebreeding I use:
import chai from 'chai';
const { assert } = chai;
© 2022 - 2024 — McMap. All rights reserved.