Skip to content

Commit

Permalink
Feature/dom testing library (#226)
Browse files Browse the repository at this point in the history
* test: adds Jest and DOM Testing Library
* test: adds tests for isTabbable
* test: adds tests for isFocusable
* test: adds tests for tabbable
* test: adds tests for focusable
* chore: configures eslint for use with jest
* chore: configures jest script to run with other tests
* test: allows Jest and Karma to co-exist
* fix: removes references to xlink:href support
* chore: removes all Karma-related code
* test: updates test fixtures imports
* test: appends all test content to the document body
* chore: adds patch changeset
* chore: removes mocha from eslint config and Jest from contributing docs
  • Loading branch information
thawkin3 committed Feb 19, 2021
1 parent a5b32ec commit f9f6d25
Show file tree
Hide file tree
Showing 16 changed files with 3,102 additions and 1,353 deletions.
5 changes: 5 additions & 0 deletions .changeset/young-toes-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tabbable': patch
---

Replaces Karma/Mocha/Sinon/Chai in test suite with Jest/Dom Testing Library. Removes README reference to identifying anchor tags with an `xlink:href` attribute as tabbable since that information is incorrect.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
dist
node_modules
**/*-bundle.js
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
es6: true,
commonjs: true,
browser: true,
mocha: true,
jest: true,
},
rules: {
//// possible errors
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
dist
node_modules
**/*-bundle.js
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ The following are considered tabbable:
- `<input>` elements
- `<select>` elements
- `<textarea>` elements
- `<a>` elements with `href` or `xlink:href` attributes
- `<audio>` and `<videos>` elements with `controls` attributes
- `<a>` elements with an `href` attribute
- `<audio>` and `<video>` elements with `controls` attributes
- the first `<summary>` element directly under a `<details>` element
- `<details>` element without a `<summary>` element
- elements with the `[contenteditable]` attribute
Expand Down
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ module.exports = {
],
plugins,
},
test: {
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
},
},
};
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
clearMocks: true,
collectCoverageFrom: ['<rootDir>/src/*.js'],
coverageDirectory: 'coverage',
coverageProvider: 'v8',
setupFilesAfterEnv: ['regenerator-runtime/runtime', './setupTests.js'],
testMatch: ['<rootDir>/test/**/*.test.js'],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
};
27 changes: 0 additions & 27 deletions karma.conf.js

This file was deleted.

16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"format:watch": "onchange \"{*,src/**/*,test/**/*,.github/workflows/*}.+(js|yml)\" -- prettier --write {{changed}}",
"lint": "eslint \"*.js\" \"src/**/*.js\" \"test/**/*.js\"",
"start": "yarn compile:cjs && budo -l -d -o test/debug.js -- -t brfs",
"test:unit": "yarn compile:cjs && karma start",
"test:unit": "jest",
"test:types": "tsc index.d.ts",
"test": "yarn format:check && yarn lint && yarn test:unit && yarn test:types",
"prepare": "yarn build",
Expand Down Expand Up @@ -56,30 +56,26 @@
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@testing-library/dom": "^7.29.4",
"@testing-library/jest-dom": "^5.11.9",
"@types/node": "^14.14.28",
"all-contributors-cli": "^6.20.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"brfs": "^2.0.2",
"browserify": "^17.0.0",
"budo": "^11.6.4",
"chai": "^4.3.0",
"cross-env": "^7.0.3",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-import": "^2.22.1",
"karma": "^6.1.1",
"karma-browserify": "^8.0.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^8.3.0",
"jest": "^26.6.3",
"jest-watch-typeahead": "^0.6.1",
"onchange": "^7.1.0",
"prettier": "^2.2.1",
"rollup": "^2.39.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2",
"sinon": "^9.2.4",
"typescript": "^4.1.5",
"watchify": "^3.11.1"
}
Expand Down
1 change: 1 addition & 0 deletions setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('@testing-library/jest-dom/extend-expect');
Loading

0 comments on commit f9f6d25

Please sign in to comment.