Skip to content

Commit

Permalink
Merge pull request #2366 from dfreeman/type-declarations
Browse files Browse the repository at this point in the history
Add TS declaration for `setupMirage`
  • Loading branch information
SergeAstapov authored Feb 21, 2022
2 parents 264be8a + 77e7ebb commit 806aee5
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,12 @@ module.exports = {
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},
{
// types tests
files: ['types-tests/**/*.ts'],
rules: {
'ember/no-test-support-import': 'off',
},
},
],
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"test:ember": "ember test",
"test:ember-compatibility": "ember try:each",
"test:test-projects": "./scripts/test.sh",
"test:types": "tsc --project types-tests",
"prepare": "./scripts/link.sh"
},
"dependencies": {
Expand Down Expand Up @@ -74,6 +75,7 @@
"@embroider/test-setup": "^1.0.0",
"@glimmer/component": "^1.0.4",
"@glimmer/tracking": "^1.0.4",
"@types/qunit": "^2.11.3",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~4.1.0",
Expand Down Expand Up @@ -119,6 +121,7 @@
"prettier": "^2.5.1",
"qunit": "^2.17.2",
"qunit-dom": "^2.0.0",
"typescript": "^4.5.5",
"webpack": "^5.66.0"
},
"resolutions": {
Expand Down
11 changes: 11 additions & 0 deletions test-support.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
interface TestHooks {
beforeEach(callback: () => void): void;
afterEach(callback: () => void): void;
}

/**
* Starts the Mirage server and makes it available under
* `this.server` for any tests run within this context,
* shutting it down afterwards.
*/
export function setupMirage(hooks?: TestHooks): void;
10 changes: 10 additions & 0 deletions types-tests/test-support.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { setupMirage } from 'ember-cli-mirage/test-support';
import { module } from 'qunit';

// Mocha-style usage
setupMirage();

// QUnit-style usage
module('A Mirage test', (hooks) => {
setupMirage(hooks);
});
10 changes: 10 additions & 0 deletions types-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"strict": true,
"noEmit": true,
"baseUrl": "..",
"paths": {
"ember-cli-mirage/*": ["./*"]
}
}
}
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2725,6 +2725,11 @@
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb"
integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==

"@types/qunit@^2.11.3":
version "2.11.3"
resolved "https://registry.yarnpkg.com/@types/qunit/-/qunit-2.11.3.tgz#2900adb58eee250c96b2d33a923cc4eae70d72ba"
integrity sha512-UF/4jDehcpRlMXzKXi2Z59Id48/uYlMeUDhYdjFrVVwy30Eud/e60Ok3yVjSPlHprafj3B315uFTrF6eqQTeSw==

"@types/range-parser@*":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc"
Expand Down Expand Up @@ -15788,6 +15793,11 @@ typescript@^2.8.3:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c"
integrity sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==

typescript@^4.5.5:
version "4.5.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==

uc.micro@^1.0.0, uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
Expand Down

0 comments on commit 806aee5

Please sign in to comment.