Skip to content

Commit b8c354d

Browse files
committed
Adjust unknown test type error message
1 parent f303657 commit b8c354d

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

addon-test-support/-private/execution_context.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export function getExecutionContext(pageObjectNode) {
3535
}
3636

3737
if (!contextName) {
38-
throw new Error('Can not detect test type. Please make sure you use the latest version of "@ember/test-helpers".');
38+
throw new Error(`Looks like you attempt to access page object property outside of test context.
39+
If that's not the case, please make sure you use the latest version of "@ember/test-helpers".`);
3940
}
4041

4142
return new executioncontexts[contextName](pageObjectNode, integrationTestContext);

tests/unit/-private/supports-rfc268-test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { test, module } from 'qunit';
22
import { setupTest } from 'ember-qunit';
33
import require from 'require';
4+
import { create } from 'ember-cli-page-object';
45

56
if (require.has('@ember/test-helpers')) {
67
module('Unit | supports rfc268', function(hooks) {
8+
function getExecutionContext(pageObject) {
9+
window.require.unsee('ember-cli-page-object/test-support/-private/execution_context');
10+
return require('ember-cli-page-object/test-support/-private/execution_context').getExecutionContext(pageObject);
11+
}
12+
713
function supportsRfc268() {
814
window.require.unsee('ember-cli-page-object/test-support/-private/execution_context');
915
return require('ember-cli-page-object/test-support/-private/execution_context').supportsRfc268();
@@ -41,8 +47,13 @@ if (require.has('@ember/test-helpers')) {
4147
});
4248

4349
module('without context', function() {
44-
test('works', function(assert) {
45-
assert.notOk(supportsRfc268());
50+
test('throws', function(assert) {
51+
assert.throws(
52+
() => getExecutionContext(create()),
53+
new Error(`Looks like you attempt to access page object property outside of test context.
54+
If that's not the case, please make sure you use the latest version of "@ember/test-helpers".`),
55+
'Throws with a correct message'
56+
);
4657
});
4758
});
4859
});

0 commit comments

Comments
 (0)