Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
Add type-checking test
Browse files Browse the repository at this point in the history
This makes sure that files generated by the blueprints type-check correctly. As all tests use fixture files to test that the blueprints generate the correct output, we can just add a linting test that type-checks the existing static fixtures files, instead of running the blueprints and type-checking the output afterwards.

To make imports not cause type errors, the appropriate typing packages have been added to `devDependencies`, and `types/index.d.ts` declares all in-app modules used in the test fixtures.
  • Loading branch information
simonihmig committed Mar 17, 2019
1 parent c918a2d commit ea8d66e
Show file tree
Hide file tree
Showing 5 changed files with 377 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cache: yarn

script:
- yarn lint:js
- yarn lint:blueprints
- yarn test

# We build PRs, but don't trigger separate builds for the PR from the branch.
Expand Down
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"scripts": {
"build": "ember build",
"lint:js": "eslint .",
"lint:blueprints": "tsc -noEmit",
"start": "ember serve",
"test": "mocha --recursive node-tests"
},
Expand All @@ -37,6 +38,15 @@
},
"devDependencies": {
"@typed-ember/renovate-config": "1.2.1",
"@types/chai": "^4.1.7",
"@types/ember": "^3.0.29",
"@types/ember-mocha": "^0.14.6",
"@types/ember-qunit": "^3.4.6",
"@types/ember-test-helpers": "^1.0.5",
"@types/ember-testing-helpers": "^0.0.3",
"@types/ember__test-helpers": "^0.7.8",
"@types/mocha": "^5.2.6",
"@types/qunit": "^2.5.4",
"broccoli-asset-rev": "3.0.0",
"ember-ajax": "5.0.0",
"ember-cli": "github:ember-cli/ember-cli#f724919b2d0455899411908531c9179240f5ef41",
Expand All @@ -63,7 +73,8 @@
"loader.js": "4.7.0",
"mocha": "6.0.2",
"qunit-dom": "0.8.4",
"testdouble": "3.11.0"
"testdouble": "3.11.0",
"typescript": "^3.3.3333"
},
"engines": {
"node": "6.* || 8.* || >= 10.*"
Expand Down
33 changes: 33 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"compilerOptions": {
"target": "es2017",
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noEmitOnError": false,
"noEmit": true,
"inlineSourceMap": true,
"inlineSources": true,
"baseUrl": ".",
"module": "es6",
"skipLibCheck": true,
"paths": {
"*": [
"types/*"
]
}
},
"include": [
"node-tests/fixtures/**/*",
"types/**/*"
]
}
16 changes: 16 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
declare module "dummy/utils/foo-bar";
declare module "dummy/utils/foo/bar-baz";
declare module "dummy/initializers/foo";
declare module "dummy/instance-initializers/foo";
declare module "my-addon/helpers/foo/bar-baz";
declare module "my-addon/mixins/foo";
declare module "my-app/helpers/foo/bar-baz";
declare module "my-app/initializers/foo";
declare module "my-app/init/initializers/foo";
declare module "my-app/instance-initializers/foo";
declare module "my-app/init/instance-initializers/foo";
declare module "my-app/mixins/foo";
declare module "my-app/tests/helpers/module-for-acceptance";
declare module "my-app/tests/helpers/start-app";
declare module "my-app/utils/foo-bar";
declare module "my-app/utils/foo/bar-baz";
Loading

0 comments on commit ea8d66e

Please sign in to comment.