Skip to content

Commit

Permalink
test: Use the ES modules directly (#385)
Browse files Browse the repository at this point in the history
This avoids the need for the generated CJS files and use of rollup in testing.

Thanks to https://remysharp.com/2019/08/16/build-free-code-and-testing-es-module-imports and avajs/ava#2417 (comment) :-).
  • Loading branch information
matatk authored Jul 28, 2020
1 parent 3e08100 commit 20683b2
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 42 deletions.
12 changes: 7 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
"node": true
},
"extends": "eslint:recommended",
"overrides": [{
"files": ["test/rollup.config.js"],
"parserOptions": {
"sourceType": "module"
"overrides": [
{
"files": ["test/test*.js"],
"parserOptions": {
"sourceType": "module"
}
}
}],
],
"parserOptions": {
"ecmaVersion": 2018
},
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ build
meta/out-*.png
landmarks-*.zip
npm-debug.log
generated-*.js
trace--*.json
times--*.json
_site
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"start:edge": "npm run start:_core -- --source-dir build/edge --target chromium --chromium-binary '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge'",
"start:firefox": "npm run start:_core -- --source-dir build/firefox",
"start:opera": "npm run start:_core -- --source-dir build/opera --target chromium --chromium-binary /Applications/Opera.app/Contents/MacOS/opera",
"pretest": "eslint . && rollup -c test/rollup.config.js",
"test": "npx nyc --exclude 'test/test*js' --reporter text --reporter html ava && npm run test:css",
"pretest": "eslint .",
"test": "npx nyc --reporter text --reporter html ava && npm run test:css",
"test:css": "npx stylelint --config .stylelintrc.json src/**/*.css",
"version": "standard-version --tag-prefix="
},
Expand All @@ -27,8 +27,10 @@
"files": [
"!test/generated-*.js",
"!test/rollup.config.js"
]
],
"require": ["esm"]
},
"nyc": { "require": ["esm"] },
"devDependencies": {
"addons-linter": "^2.1.0",
"archiver-promise": "~1.0",
Expand All @@ -37,6 +39,7 @@
"deepmerge": "~4.2",
"dependency-tree": "^7.2.1",
"eslint": "^7.5.0",
"esm": "^3.2.25",
"fs-extra": "^9.0.1",
"husky": "^4.2.5",
"jsdom": "^16.3.0",
Expand Down
22 changes: 0 additions & 22 deletions test/rollup.config.js

This file was deleted.

5 changes: 2 additions & 3 deletions test/testContrastChecker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'
const test = require('ava')
const ContrastChecker = require('./generated-contrast-checker.js')
import test from 'ava'
import ContrastChecker from '../src/code/contrastChecker'

const contrastChecker = new ContrastChecker()

Expand Down
9 changes: 4 additions & 5 deletions test/testLandmarksFinder.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict'
const test = require('ava')
const jsdom = require('jsdom')
const pssst = require('page-structural-semantics-scanner-tests')
const LandmarksFinder = require('./generated-landmarks-finder')
import test from 'ava'
import jsdom from 'jsdom'
import pssst from 'page-structural-semantics-scanner-tests'
import LandmarksFinder from '../src/code/landmarksFinder'

const { JSDOM } = jsdom
const checks = pssst.getFullPageTestsInline()
Expand Down
5 changes: 2 additions & 3 deletions test/testMigrationManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-prototype-builtins */
'use strict'
const test = require('ava')
const MigrationManager = require('./generated-migration-manager.js')
import test from 'ava'
import MigrationManager from '../src/code/migrationManager'

// The purpose of the migration manager is to delete obsolete user settings, or
// rename existing user settings to their current names. Landmarks ships with
Expand Down

0 comments on commit 20683b2

Please sign in to comment.