Skip to content

Commit 2e232c2

Browse files
author
Spencer
authored
[@kbn/expect] "fork" expect.js into repo (#33761)
* [@kbn/expect] "fork" expect.js into repo * [eslint] autofix references to expect.js * [tslint] autofix all expect.js imports * now that expect.js is in strict mode, avoid reassigning fn.length
1 parent 2c48da2 commit 2e232c2

File tree

1,117 files changed

+2679
-1341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,117 files changed

+2679
-1341
lines changed

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ module.exports = {
4747
rules: {
4848
'no-restricted-imports': [2, restrictedModules],
4949
'no-restricted-modules': [2, restrictedModules],
50+
'@kbn/eslint/module_migration': [
51+
'error',
52+
[
53+
{
54+
from: 'expect.js',
55+
to: '@kbn/expect',
56+
},
57+
],
58+
],
5059
},
5160

5261
overrides: [

TYPESCRIPT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ If yarn doesn't find the module it may not have types. For example, our `rison_
111111

112112
1. Contribute types into the DefinitelyTyped repo itself, or
113113
2. Create a top level `types` folder and point to that in the tsconfig. For example, Infra team already handled this for `rison_node` and added: `x-pack/plugins/infra/types/rison_node.d.ts`. Other code uses it too so we will need to pull it up. Or,
114-
3. Add a `// @ts-ignore` line above the import. This should be used minimally, the above options are better. However, sometimes you have to resort to this method. For example, the `expect.js` module will require this line. We don't have type definitions installed for this library. Installing these types would conflict with the jest typedefs for expect, and since they aren't API compatible with each other, it's not possible to make both test frameworks happy. Since we are moving from mocha => jest, we don't see this is a big issue.
114+
3. Add a `// @ts-ignore` line above the import. This should be used minimally, the above options are better. However, sometimes you have to resort to this method.
115115

116116
### TypeScripting react files
117117

docs/development/core/development-functional-tests.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Use the `--help` flag for more options.
8282
[float]
8383
===== Environment
8484

85-
The tests are written in https://mochajs.org[mocha] using https://github.com/Automattic/expect.js[expect] for assertions.
85+
The tests are written in https://mochajs.org[mocha] using https://github.com/elastic/kibana/tree/master/packages/kbn-expect[@kbn/expect] for assertions.
8686

8787
We use https://sites.google.com/a/chromium.org/chromedriver/[chromedriver], https://theintern.github.io/leadfoot[leadfoot], and https://github.com/theintern/digdug[digdug] for automating Chrome. When the `FunctionalTestRunner` launches, digdug opens a `Tunnel` which starts chromedriver and a stripped-down instance of Chrome. It also creates an instance of https://theintern.github.io/leadfoot/module-leadfoot_Command.html[Leadfoot's `Command`] class, which is available via the `remote` service. The `remote` communicates to Chrome through the digdug `Tunnel`. See the https://theintern.github.io/leadfoot/module-leadfoot_Command.html[leadfoot/Command API] docs for all the commands you can use with `remote`.
8888

@@ -122,11 +122,11 @@ A test suite is a collection of tests defined by calling `describe()`, and then
122122
[float]
123123
===== Anatomy of a test file
124124

125-
The annotated example file below shows the basic structure every test suite uses. It starts by importing https://github.com/Automattic/expect.js[`expect.js`] and defining its default export: an anonymous Test Provider. The test provider then destructures the Provider API for the `getService()` and `getPageObjects()` functions. It uses these functions to collect the dependencies of this suite. The rest of the test file will look pretty normal to mocha.js users. `describe()`, `it()`, `before()` and the lot are used to define suites that happen to automate a browser via services and objects of type `PageObject`.
125+
The annotated example file below shows the basic structure every test suite uses. It starts by importing https://github.com/elastic/kibana/tree/master/packages/kbn-expect[`@kbn/expect`] and defining its default export: an anonymous Test Provider. The test provider then destructures the Provider API for the `getService()` and `getPageObjects()` functions. It uses these functions to collect the dependencies of this suite. The rest of the test file will look pretty normal to mocha.js users. `describe()`, `it()`, `before()` and the lot are used to define suites that happen to automate a browser via services and objects of type `PageObject`.
126126

127127
["source","js"]
128128
----
129-
import expect from 'expect.js';
129+
import expect from '@kbn/expect';
130130
// test files must `export default` a function that defines a test suite
131131
export default function ({ getService, getPageObject }) {
132132

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
"@kbn/es": "1.0.0",
259259
"@kbn/eslint-import-resolver-kibana": "2.0.0",
260260
"@kbn/eslint-plugin-eslint": "1.0.0",
261+
"@kbn/expect": "1.0.0",
261262
"@kbn/plugin-generator": "1.0.0",
262263
"@kbn/test": "1.0.0",
263264
"@octokit/rest": "^15.10.0",
@@ -346,7 +347,6 @@
346347
"eslint-plugin-prefer-object-spread": "^1.2.1",
347348
"eslint-plugin-prettier": "^2.6.2",
348349
"eslint-plugin-react": "^7.11.1",
349-
"expect.js": "0.3.1",
350350
"faker": "1.1.0",
351351
"fetch-mock": "7.3.0",
352352
"geckodriver": "1.12.2",

packages/elastic-datemath/test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import dateMath from '../src/index';
2121
import moment from 'moment';
2222
import sinon from 'sinon';
23-
import expect from 'expect.js';
23+
import expect from '@kbn/expect';
2424

2525
/**
2626
* Require a new instance of the moment library, bypassing the require cache.

packages/kbn-dev-utils/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
},
2121
"devDependencies": {
2222
"@kbn/babel-preset": "1.0.0",
23+
"@kbn/expect": "1.0.0",
2324
"babel-cli": "^6.26.0",
24-
"chance": "1.0.6",
25-
"expect.js": "0.3.1"
25+
"chance": "1.0.6"
2626
}
2727
}

packages/kbn-es-query/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"@babel/preset-typescript": "^7.3.3",
2323
"@kbn/babel-preset": "1.0.0",
2424
"@kbn/dev-utils": "1.0.0",
25+
"@kbn/expect": "1.0.0",
2526
"del": "^3.0.0",
26-
"expect.js": "0.3.1",
2727
"getopts": "^2.2.3",
2828
"supports-color": "^6.1.0",
2929
"typescript": "^3.3.3333"

packages/kbn-es-query/src/es_query/__tests__/_migrate_filter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import expect from 'expect.js';
20+
import expect from '@kbn/expect';
2121
import _ from 'lodash';
2222
import { migrateFilter } from '../migrate_filter';
2323

packages/kbn-es-query/src/es_query/__tests__/build_es_query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import expect from 'expect.js';
20+
import expect from '@kbn/expect';
2121
import { buildEsQuery } from '../build_es_query';
2222
import indexPattern from '../../__fixtures__/index_pattern_response.json';
2323
import { fromKueryExpression, toElasticsearchQuery } from '../../kuery';

packages/kbn-es-query/src/es_query/__tests__/decorate_query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import expect from 'expect.js';
20+
import expect from '@kbn/expect';
2121
import { decorateQuery } from '../decorate_query';
2222

2323
describe('Query decorator', function () {

0 commit comments

Comments
 (0)