Skip to content

Instantly share code, notes, and snippets.

@rauschma
Last active Feb 4, 2021
Embed
What would you like to do?

Using the “JS for impatient programmers” exercise setup with latest language features

Instructions:

  • Replace the existing package.json with the file shown here.
  • Execute in the shell:
    cd impatient-js-code*
    rm -rf node_modules
    npm install
    
  • If you move nullish-coalescing_test.mjs into the directory, you can run it as follows:
    npm t nullish-coalescing_test.mjs
    
import test from 'ava';
import * as assert from 'assert/strict';
test('nullish coalescing operator', () => {
assert.equal(undefined ?? 'abc', 'abc');
});
{
"author": "Axel Rauschmayer",
"private": true,
"scripts": {
"test": "ava --match \"!*#bonus\"",
"testall": "ava",
"serve": "http-server test_data/"
},
"// dependencies": [
"http-server is needed for fetch_json_test.mjs and fetch_json_test2.mjs",
"isomorphic-fetch is needed for fetch_json_test.mjs and fetch_json_test2.mjs"
],
"dependencies": {
"ava": "^3.15.0",
"esm": "^3.2.25",
"http-server": "^0.12.3",
"isomorphic-fetch": "^3.0.0"
},
"// ava": [
"failWithoutAssertions must be false, because assert.* is not tracked by AVA",
"esm is needed to run ESM-based tests on older Node.js versions"
],
"ava": {
"files": [
"**/*.mjs"
],
"extensions": [
"mjs"
],
"require": [
"esm"
],
"failWithoutAssertions": false
}
}
@mday64

This comment has been minimized.

Copy link

@mday64 mday64 commented Jan 30, 2021

I had to change the second import to:
import {strict as assert} from 'assert';

Other than that, it worked great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment