mirror of
https://github.com/jlengrand/open-wc.git
synced 2026-03-10 08:31:19 +00:00
feat: add type definition files for testing
This commit is contained in:
@@ -14,7 +14,7 @@ jobs:
|
|||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
# Download and cache dependencies
|
# Download and cache dependencies
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- v3-dependencies-{{ checksum "package.json" }}
|
- v3-dependencies-{{ checksum "package.json" }}
|
||||||
@@ -29,6 +29,9 @@ jobs:
|
|||||||
# build what needs to be build so we can use it in the next steps
|
# build what needs to be build so we can use it in the next steps
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
||||||
|
# auto build typescript definition files (not part of build as locally JsDoc alone is all we need)
|
||||||
|
- run: npm run build:types
|
||||||
|
|
||||||
# run lint
|
# run lint
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
|
|
||||||
@@ -48,7 +51,7 @@ jobs:
|
|||||||
at: ~/repo
|
at: ~/repo
|
||||||
- add_ssh_keys:
|
- add_ssh_keys:
|
||||||
fingerprints:
|
fingerprints:
|
||||||
- "3f:ea:54:b7:77:13:b6:cf:29:90:2b:19:bb:eb:b5:f1"
|
- '3f:ea:54:b7:77:13:b6:cf:29:90:2b:19:bb:eb:b5:f1'
|
||||||
- run:
|
- run:
|
||||||
name: Authenticate with registry
|
name: Authenticate with registry
|
||||||
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "lerna run build",
|
"build": "lerna run build",
|
||||||
|
"build:types": "tsc -p tsconfig.build.types.json",
|
||||||
"lint": "run-p lint:*",
|
"lint": "run-p lint:*",
|
||||||
"lint:eslint": "eslint --ext .js,.html .",
|
"lint:eslint": "eslint --ext .js,.html .",
|
||||||
"lint:prettier": "prettier \"**/*.js\" --list-different || (echo '↑↑ these files are not prettier formatted ↑↑' && exit 1)",
|
"lint:prettier": "prettier \"**/*.js\" --list-different || (echo '↑↑ these files are not prettier formatted ↑↑' && exit 1)",
|
||||||
@@ -56,7 +57,7 @@
|
|||||||
"lint-staged": "^9.2.0",
|
"lint-staged": "^9.2.0",
|
||||||
"npm-run-all": "4.1.3",
|
"npm-run-all": "4.1.3",
|
||||||
"prettier": "^1.18.2",
|
"prettier": "^1.18.2",
|
||||||
"typescript": "^3.3.3333",
|
"typescript-temporary-fork-for-jsdoc": "^3.6.0-insiders.20190802",
|
||||||
"vuepress": "^1.0.0-alpha.30",
|
"vuepress": "^1.0.0-alpha.30",
|
||||||
"webpack-merge": "^4.1.5"
|
"webpack-merge": "^4.1.5"
|
||||||
}
|
}
|
||||||
|
|||||||
12
packages/chai-a11y-axe/chai-a11y-axe-plugin.d.ts
vendored
Normal file
12
packages/chai-a11y-axe/chai-a11y-axe-plugin.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/// <reference types="chai" />
|
||||||
|
|
||||||
|
declare namespace Chai {
|
||||||
|
interface Assertion {
|
||||||
|
accessible(options?: Object): Assertion;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Assert {
|
||||||
|
isAccessible(fixture: any, options?: Object): Assertion;
|
||||||
|
isNotAccessible(fixture: any, options?: Object): Assertion;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
packages/chai-a11y-axe/index.d.ts
vendored
Normal file
1
packages/chai-a11y-axe/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { chaiA11yAxe } from "./src/accessible.js";
|
||||||
7
packages/chai-a11y-axe/src/accessible.d.ts
vendored
Normal file
7
packages/chai-a11y-axe/src/accessible.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/// <reference path="../chai-a11y-axe-plugin.d.ts" />
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} chai
|
||||||
|
* @param {any} utils
|
||||||
|
*/
|
||||||
|
export const chaiA11yAxe: (chai: any, utils: any) => void;
|
||||||
17
packages/semantic-dom-diff/chai-dom-diff-plugin.d.ts
vendored
Normal file
17
packages/semantic-dom-diff/chai-dom-diff-plugin.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/// <reference types="chai" />
|
||||||
|
|
||||||
|
declare namespace Chai {
|
||||||
|
interface Assertion {
|
||||||
|
dom: Assertion;
|
||||||
|
lightDom: Assertion;
|
||||||
|
shadowDom: Assertion;
|
||||||
|
equalSnapshot(options?: Object): Assertion;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Assert {
|
||||||
|
dom: Assertion;
|
||||||
|
lightDom: Assertion;
|
||||||
|
shadowDom: Assertion;
|
||||||
|
equalSnapshot(fixture: any, options?: Object): Assertion;
|
||||||
|
}
|
||||||
|
}
|
||||||
7
packages/semantic-dom-diff/chai-dom-diff.d.ts
vendored
Normal file
7
packages/semantic-dom-diff/chai-dom-diff.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/// <reference path="chai-dom-diff-plugin.d.ts" />
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} chai
|
||||||
|
* @param {any} utils
|
||||||
|
*/
|
||||||
|
export const chaiDomDiff: (chai: any, utils: any) => void;
|
||||||
3
packages/semantic-dom-diff/index.d.ts
vendored
Normal file
3
packages/semantic-dom-diff/index.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export { chaiDomDiff } from "./chai-dom-diff.js";
|
||||||
|
import { getDiffableHTML } from "./get-diffable-html.js";
|
||||||
|
export { getDiffableHTML, getDiffableHTML as getDiffableSemanticHTML };
|
||||||
13
packages/semantic-dom-diff/test/bdd-setup.d.ts
vendored
Normal file
13
packages/semantic-dom-diff/test/bdd-setup.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/// <reference path="../chai-dom-diff-plugin.d.ts" />
|
||||||
|
|
||||||
|
import chai from 'chai';
|
||||||
|
|
||||||
|
type expect = typeof chai.expect;
|
||||||
|
type assert = typeof chai.assert;
|
||||||
|
type should = typeof chai.should;
|
||||||
|
|
||||||
|
declare function expect(...args: Parameters<expect>): ReturnType<expect>;
|
||||||
|
declare const assert: assert;
|
||||||
|
declare function should(...args: Parameters<should>): ReturnType<should>;
|
||||||
|
|
||||||
|
export { expect, assert, should };
|
||||||
@@ -10,7 +10,9 @@ describe('dom', () => {
|
|||||||
|
|
||||||
it('passes along provided configuration', async () => {
|
it('passes along provided configuration', async () => {
|
||||||
const el = await fixture('<div foo="bar"></div>');
|
const el = await fixture('<div foo="bar"></div>');
|
||||||
|
// @ts-ignore
|
||||||
expect(el).dom.to.equal('<div></div>', { ignoreAttributes: ['foo'] });
|
expect(el).dom.to.equal('<div></div>', { ignoreAttributes: ['foo'] });
|
||||||
|
// @ts-ignore
|
||||||
assert.dom.equal(el, '<div></div>', { ignoreAttributes: ['foo'] });
|
assert.dom.equal(el, '<div></div>', { ignoreAttributes: ['foo'] });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -24,7 +26,9 @@ describe('lightDom', () => {
|
|||||||
|
|
||||||
it('passes along provided configuration', async () => {
|
it('passes along provided configuration', async () => {
|
||||||
const el = await fixture('<div><p foo="bar">foo</p></div>');
|
const el = await fixture('<div><p foo="bar">foo</p></div>');
|
||||||
|
// @ts-ignore
|
||||||
expect(el).lightDom.to.equal('<p>foo</p>', { ignoreAttributes: ['foo'] });
|
expect(el).lightDom.to.equal('<p>foo</p>', { ignoreAttributes: ['foo'] });
|
||||||
|
// @ts-ignore
|
||||||
assert.lightDom.equal(el, '<p>foo</p>', { ignoreAttributes: ['foo'] });
|
assert.lightDom.equal(el, '<p>foo</p>', { ignoreAttributes: ['foo'] });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
11
packages/testing-helpers/test/setup.d.ts
vendored
Normal file
11
packages/testing-helpers/test/setup.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import chai from 'chai';
|
||||||
|
|
||||||
|
type expect = typeof chai.expect;
|
||||||
|
type assert = typeof chai.assert;
|
||||||
|
type should = typeof chai.should;
|
||||||
|
|
||||||
|
declare function expect(...args: Parameters<expect>): ReturnType<expect>;
|
||||||
|
declare const assert: assert;
|
||||||
|
declare function should(...args: Parameters<should>): ReturnType<should>;
|
||||||
|
|
||||||
|
export { expect, assert, should };
|
||||||
26
packages/testing/index-no-side-effects.d.ts
vendored
Normal file
26
packages/testing/index-no-side-effects.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
export { html } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { unsafeStatic } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { triggerBlurFor } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { triggerFocusFor } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { oneEvent } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { isIE } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { defineCE } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { aTimeout } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { litFixture } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { litFixtureSync } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { fixture } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { fixtureSync } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { fixtureCleanup } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
export { elementUpdated } from '@open-wc/testing-helpers/index-no-side-effects.js';
|
||||||
|
|
||||||
|
import chai from 'chai';
|
||||||
|
|
||||||
|
type expect = typeof chai.expect;
|
||||||
|
type assert = typeof chai.assert;
|
||||||
|
type should = typeof chai.should;
|
||||||
|
|
||||||
|
declare function expect(...args: Parameters<expect>): ReturnType<expect>;
|
||||||
|
declare const assert: assert;
|
||||||
|
declare function should(...args: Parameters<should>): ReturnType<should>;
|
||||||
|
|
||||||
|
export { expect, assert, should };
|
||||||
27
packages/testing/index.d.ts
vendored
Normal file
27
packages/testing/index.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
export { html } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { unsafeStatic } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { triggerBlurFor } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { triggerFocusFor } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { oneEvent } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { isIE } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { defineCE } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { aTimeout } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { nextFrame } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { litFixture } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { litFixtureSync } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { fixture } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { fixtureSync } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { fixtureCleanup } from '@open-wc/testing-helpers/index.js';
|
||||||
|
export { elementUpdated } from '@open-wc/testing-helpers/index.js';
|
||||||
|
|
||||||
|
import chai from 'chai';
|
||||||
|
|
||||||
|
type expect = typeof chai.expect;
|
||||||
|
type assert = typeof chai.assert;
|
||||||
|
type should = typeof chai.should;
|
||||||
|
|
||||||
|
declare function expect(...args: Parameters<expect>): ReturnType<expect>;
|
||||||
|
declare const assert: assert;
|
||||||
|
declare function should(...args: Parameters<should>): ReturnType<should>;
|
||||||
|
|
||||||
|
export { expect, assert, should };
|
||||||
1
packages/testing/register-chai-plugins.d.ts
vendored
Normal file
1
packages/testing/register-chai-plugins.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export {};
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
import { fixture, expect } from '../index.js';
|
import { fixture, expect } from '../index.js';
|
||||||
|
|
||||||
describe('Plugin: semantic-dom-diff', () => {
|
describe('Plugin: semantic-dom-diff', () => {
|
||||||
it('can semantically compare dom trees', async () => {
|
it('can semantically compare full dom trees', async () => {
|
||||||
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`);
|
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`);
|
||||||
expect(el).dom.to.equal('<div><h1>Hey</h1></div>');
|
expect(el).dom.to.equal('<div><h1>Hey</h1></div>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can semantically compare lightDom trees', async () => {
|
||||||
|
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`);
|
||||||
|
expect(el).lightDom.to.equal('<h1>Hey</h1>');
|
||||||
|
});
|
||||||
|
|
||||||
it('can compare against a snapshot', async () => {
|
it('can compare against a snapshot', async () => {
|
||||||
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`);
|
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`);
|
||||||
expect(el).dom.to.equalSnapshot();
|
expect(el).dom.to.equalSnapshot();
|
||||||
|
|||||||
23
tsconfig.build.types.json
Normal file
23
tsconfig.build.types.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "esnext",
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"lib": ["es2017", "dom"],
|
||||||
|
"declaration": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true,
|
||||||
|
"emitDeclarationOnly": true,
|
||||||
|
"strict": false,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"alwaysStrict": true,
|
||||||
|
"types": ["node", "mocha", "chai"],
|
||||||
|
"esModuleInterop": true
|
||||||
|
},
|
||||||
|
"files": ["browser.d.ts"],
|
||||||
|
"include": [
|
||||||
|
"packages/testing-helpers/*.js",
|
||||||
|
"packages/semantic-dom-diff/get-diffable-html.js",
|
||||||
|
"packages/semantic-dom-diff/src/utils.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -15703,6 +15703,11 @@ typeface-oswald@0.0.54:
|
|||||||
resolved "https://registry.yarnpkg.com/typeface-oswald/-/typeface-oswald-0.0.54.tgz#1e253011622cdd50f580c04e7d625e7f449763d7"
|
resolved "https://registry.yarnpkg.com/typeface-oswald/-/typeface-oswald-0.0.54.tgz#1e253011622cdd50f580c04e7d625e7f449763d7"
|
||||||
integrity sha512-U1WMNp4qfy4/3khIfHMVAIKnNu941MXUfs3+H9R8PFgnoz42Hh9pboSFztWr86zut0eXC8byalmVhfkiKON/8Q==
|
integrity sha512-U1WMNp4qfy4/3khIfHMVAIKnNu941MXUfs3+H9R8PFgnoz42Hh9pboSFztWr86zut0eXC8byalmVhfkiKON/8Q==
|
||||||
|
|
||||||
|
typescript-temporary-fork-for-jsdoc@^3.6.0-insiders.20190802:
|
||||||
|
version "3.6.0-insiders.20190802"
|
||||||
|
resolved "https://registry.yarnpkg.com/typescript-temporary-fork-for-jsdoc/-/typescript-temporary-fork-for-jsdoc-3.6.0-insiders.20190802.tgz#aece6f3f5d53c6e06e5e1c4af5a19183d7124ab6"
|
||||||
|
integrity sha512-j76opNh6ljAXDUDXr03+pOkITiATPbUlQlMp9pxD/SR3eNKAtIdHwOTf3dDspyGs8TGJQjQXMUiYqJr0gW+nCg==
|
||||||
|
|
||||||
typescript@^3.3.3333:
|
typescript@^3.3.3333:
|
||||||
version "3.5.3"
|
version "3.5.3"
|
||||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
|
||||||
|
|||||||
Reference in New Issue
Block a user