Skip to content

Instantly share code, notes, and snippets.

@rauschma
Last active February 4, 2021 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rauschma/f2ee470cb2ff1acfdf205805d3670ae1 to your computer and use it in GitHub Desktop.
Save rauschma/f2ee470cb2ff1acfdf205805d3670ae1 to your computer and use it in GitHub Desktop.

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
Copy link

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