forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.0] [ts] add script to verify that all ts is in a project (elastic#…
…32727) (elastic#32827) * [ts] add script to verify that all ts is in a project (elastic#32727) Based on elastic#32705 We currently have TypeScript code that was backported to 7.0, which was backported without issue because it falls outside of any TypeScript projects in 7.0. This means that the pre-commit hooks break on changes to these files, and that they are not getting type checked by the type_check script. To fix this we need to verify that every typescript file in the repository is covered by a tsconfig.json file as part of CI. * tests typescript migration (elastic#31234) * add typescript support for functional tests * [ts][ftr] improve types for ftr and expect.js, cleanup changes to tsconfig files (elastic#31948) In elastic#31234 there were some extra changes that I've reverted, like use of the `tsconfig-paths` package to magically rewrite import statements to defy the standard node module resolution algorithm, the inclusion of several unnecessary options in the `test/tsconfig.json` file, and changes of the line-endings in the config files. This also brings a few enhancements from elastic#30190 including a modularized version of the expect.js types, and options for explicit mappings for the PageObjects and services used in ftr tests. # Conflicts: # src/functional_test_runner/lib/config/schema.js # test/common/services/es.ts # test/functional/page_objects/index.ts # test/functional/services/apps_menu.js # yarn.lock
- Loading branch information
Spencer
authored
Mar 9, 2019
1 parent
2c31657
commit 2c2637d
Showing
54 changed files
with
1,529 additions
and
682 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": [ | ||
"src/**/*.ts", | ||
"src/**/*.tsx", | ||
"types/intl_format_cache.d.ts", | ||
"types/intl_relativeformat.d.ts" | ||
], | ||
"exclude": [ | ||
"target" | ||
], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationDir": "./target/types", | ||
} | ||
} | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": [ | ||
"src/**/*.ts", | ||
"src/**/*.tsx", | ||
"types/intl_format_cache.d.ts", | ||
"types/intl_relativeformat.d.ts" | ||
], | ||
"exclude": [ | ||
"target" | ||
], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationDir": "./target/types", | ||
"types": [ | ||
"jest", | ||
"node" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"exclude": [ | ||
"dist" | ||
], | ||
"include": [ | ||
"./src/**/*.ts", | ||
"./types/index.d.ts" | ||
] | ||
} | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"exclude": [ | ||
"dist" | ||
], | ||
"include": [ | ||
"./src/**/*.ts", | ||
"./types/index.d.ts" | ||
], | ||
"compilerOptions": { | ||
"types": [ | ||
"jest", | ||
"node" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": [ | ||
"types/**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# @kbn/test/types | ||
|
||
Shared types used by different parts of the tests | ||
|
||
- **`expect.js.d.ts`**: This is a fork of the expect.js types that have been slightly modified to only expose a module type for `import expect from 'expect.js'` statements. The `@types/expect.js` includes types for the `expect` global, which is useful for some uses of the library but conflicts with the jest types we use. Making the type "module only" prevents them from conflicting. | ||
- **`ftr.d.ts`**: These types are generic types for using the functional test runner. They are here because we plan to move the functional test runner into the `@kbn/test` package at some point and having them here makes them a lot easier to import from all over the place like we do. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
// tslint:disable | ||
|
||
// Type definitions for expect.js 0.3.1 | ||
// Project: https://github.com/Automattic/expect.js | ||
// Definitions by: Teppei Sato <https://github.com/teppeis> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// License: MIT | ||
|
||
declare module 'expect.js' { | ||
function expect(target?: any): Root; | ||
|
||
interface Assertion { | ||
/** | ||
* Assert typeof / instanceof. | ||
*/ | ||
an: An; | ||
/** | ||
* Check if the value is truthy | ||
*/ | ||
ok(): void; | ||
|
||
/** | ||
* Creates an anonymous function which calls fn with arguments. | ||
*/ | ||
withArgs(...args: any[]): Root; | ||
|
||
/** | ||
* Assert that the function throws. | ||
* | ||
* @param fn callback to match error string against | ||
*/ | ||
throwError(fn?: (exception: any) => void): void; | ||
|
||
/** | ||
* Assert that the function throws. | ||
* | ||
* @param fn callback to match error string against | ||
*/ | ||
throwException(fn?: (exception: any) => void): void; | ||
|
||
/** | ||
* Assert that the function throws. | ||
* | ||
* @param regexp regexp to match error string against | ||
*/ | ||
throwError(regexp: RegExp): void; | ||
|
||
/** | ||
* Assert that the function throws. | ||
* | ||
* @param fn callback to match error string against | ||
*/ | ||
throwException(regexp: RegExp): void; | ||
|
||
/** | ||
* Checks if the array is empty. | ||
*/ | ||
empty(): Assertion; | ||
|
||
/** | ||
* Checks if the obj exactly equals another. | ||
*/ | ||
equal(obj: any): Assertion; | ||
|
||
/** | ||
* Checks if the obj sortof equals another. | ||
*/ | ||
eql(obj: any): Assertion; | ||
|
||
/** | ||
* Assert within start to finish (inclusive). | ||
* | ||
* @param start | ||
* @param finish | ||
*/ | ||
within(start: number, finish: number): Assertion; | ||
|
||
/** | ||
* Assert typeof. | ||
*/ | ||
a(type: string): Assertion; | ||
|
||
/** | ||
* Assert instanceof. | ||
*/ | ||
a(type: Function): Assertion; | ||
|
||
/** | ||
* Assert numeric value above n. | ||
*/ | ||
greaterThan(n: number): Assertion; | ||
|
||
/** | ||
* Assert numeric value above n. | ||
*/ | ||
above(n: number): Assertion; | ||
|
||
/** | ||
* Assert numeric value below n. | ||
*/ | ||
lessThan(n: number): Assertion; | ||
|
||
/** | ||
* Assert numeric value below n. | ||
*/ | ||
below(n: number): Assertion; | ||
|
||
/** | ||
* Assert string value matches regexp. | ||
* | ||
* @param regexp | ||
*/ | ||
match(regexp: RegExp): Assertion; | ||
|
||
/** | ||
* Assert property "length" exists and has value of n. | ||
* | ||
* @param n | ||
*/ | ||
length(n: number): Assertion; | ||
|
||
/** | ||
* Assert property name exists, with optional val. | ||
* | ||
* @param name | ||
* @param val | ||
*/ | ||
property(name: string, val?: any): Assertion; | ||
|
||
/** | ||
* Assert that string contains str. | ||
*/ | ||
contain(str: string): Assertion; | ||
string(str: string): Assertion; | ||
|
||
/** | ||
* Assert that the array contains obj. | ||
*/ | ||
contain(obj: any): Assertion; | ||
string(obj: any): Assertion; | ||
|
||
/** | ||
* Assert exact keys or inclusion of keys by using the `.own` modifier. | ||
*/ | ||
key(keys: string[]): Assertion; | ||
/** | ||
* Assert exact keys or inclusion of keys by using the `.own` modifier. | ||
*/ | ||
key(...keys: string[]): Assertion; | ||
/** | ||
* Assert exact keys or inclusion of keys by using the `.own` modifier. | ||
*/ | ||
keys(keys: string[]): Assertion; | ||
/** | ||
* Assert exact keys or inclusion of keys by using the `.own` modifier. | ||
*/ | ||
keys(...keys: string[]): Assertion; | ||
|
||
/** | ||
* Assert a failure. | ||
*/ | ||
fail(message?: string): Assertion; | ||
} | ||
|
||
interface Root extends Assertion { | ||
not: Not; | ||
to: To; | ||
only: Only; | ||
have: Have; | ||
be: Be; | ||
} | ||
|
||
interface Be extends Assertion { | ||
/** | ||
* Checks if the obj exactly equals another. | ||
*/ | ||
(obj: any): Assertion; | ||
|
||
an: An; | ||
} | ||
|
||
interface An extends Assertion { | ||
/** | ||
* Assert typeof. | ||
*/ | ||
(type: string): Assertion; | ||
|
||
/** | ||
* Assert instanceof. | ||
*/ | ||
(type: Function): Assertion; | ||
} | ||
|
||
interface Not extends NotBase { | ||
to: ToBase; | ||
} | ||
|
||
interface NotBase extends Assertion { | ||
be: Be; | ||
have: Have; | ||
include: Assertion; | ||
only: Only; | ||
} | ||
|
||
interface To extends ToBase { | ||
not: NotBase; | ||
} | ||
|
||
interface ToBase extends Assertion { | ||
be: Be; | ||
have: Have; | ||
include: Assertion; | ||
only: Only; | ||
} | ||
|
||
interface Only extends Assertion { | ||
have: Have; | ||
} | ||
|
||
interface Have extends Assertion { | ||
own: Assertion; | ||
} | ||
|
||
export default expect; | ||
} |
Oops, something went wrong.