-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(internal) add @warp-drive/diagnostic/ember (#9009)
* chore(internal) add @warp-drive/diagnostic/ember * chore(private): add setup to @warp-drive/diagnostic/ember * stash * make diagnostic behave like an addon when needed * maybe can do less
- Loading branch information
Showing
49 changed files
with
300 additions
and
364 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
|
||
const { addonV1Shim } = require('@embroider/addon-shim'); | ||
module.exports = addonV1Shim(__dirname); |
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
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { getTestMetadata, setupContext, SetupContextOptions, teardownContext, TestContext } from '@ember/test-helpers'; | ||
import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; | ||
|
||
import type { Hooks } from './-types'; | ||
|
||
import { setupGlobalHooks } from './internals/config'; | ||
|
||
// fix bug with embroider/webpack/auto-import and test-loader | ||
// @ts-expect-error | ||
const CLITestLoader: typeof AbstractTestLoader = AbstractTestLoader.default ? AbstractTestLoader.default : AbstractTestLoader; | ||
|
||
export function setupTest(hooks: Hooks<TestContext>, opts?: SetupContextOptions) { | ||
const options = { waitForSettled: false, ...opts }; | ||
|
||
hooks.beforeEach(async function () { | ||
let testMetadata = getTestMetadata(this); | ||
testMetadata.framework = 'qunit'; | ||
|
||
await setupContext(this, options); | ||
}); | ||
|
||
hooks.afterEach(function (this: TestContext) { | ||
return teardownContext(this, options); | ||
}); | ||
} | ||
|
||
let moduleLoadFailures: Error[] = []; | ||
|
||
class TestLoader extends CLITestLoader { | ||
moduleLoadFailure(moduleName: string, error: Error) { | ||
moduleLoadFailures.push(error); | ||
} | ||
} | ||
|
||
/** | ||
Load tests following the default patterns: | ||
* The module name ends with `-test` | ||
* The module name ends with `.jshint` | ||
@method loadTests | ||
*/ | ||
function loadTests() { | ||
TestLoader.load(); | ||
} | ||
|
||
export function configure() { | ||
setupGlobalHooks((hooks) => { | ||
hooks.onSuiteFinish(() => { | ||
let length = moduleLoadFailures.length; | ||
|
||
try { | ||
if (length === 0) { | ||
// do nothing | ||
} else if (length === 1) { | ||
throw moduleLoadFailures[0]; | ||
} else { | ||
throw new Error('\n' + moduleLoadFailures.join('\n')); | ||
} | ||
} finally { | ||
// ensure we release previously captured errors. | ||
moduleLoadFailures = []; | ||
} | ||
}); | ||
}); | ||
|
||
loadTests(); | ||
} |
Oops, something went wrong.