Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme shows invalid function type passed to before block (functional tests) #39

Open
justinbc820 opened this issue Nov 21, 2017 · 3 comments

Comments

@justinbc820
Copy link

justinbc820 commented Nov 21, 2017

Expected behavior

In the Readme, the before block in a functional suite should take a SuiteLifecycleFunction, which returns PromiseLike.

Current behavior

The readme shows the function passed to the before block returning Promise<Command, any>.

Possible solution

before(async ({ remote }) => {
	await remote
		.get('_dist/src/index.html')
		.setFindTimeout(5000)
		.findDisplayedByCssSelector('body.loaded');
});

/***** OR *****/

before(({ remote }) => {
	return remote
		.get('_dist/src/index.html')
		.setFindTimeout(5000)
		.findDisplayedByCssSelector('body.loaded')
		.end();
});

Steps to reproduce (for bugs)

no steps, just look in the readme. Typescript just complains about the wrong type being returned.

Environment

Example (e.g., dojo, backbone, etc.):
Intern version:
Node version:
NPM version:
Browser version:

Additional information

@justinbc820 justinbc820 changed the title Tutorial shows invalid function type passed to before block Readme shows invalid function type passed to before block (functional tests) Nov 21, 2017
@jason0x43
Copy link
Member

Hmm...this is actually a bug (or at least an inconvenience) in the Intern typings. SuiteLifeCycleFunction shouldn't care about the resolution type of a Promise. findDisplayedByCssSelector returns essentially a PromiseLike<Element> which should be fine; all Intern really cares about is whether or not the return type is a PromiseLike so it knows whether to wait for it to resolve. However, the current typings explicitly expect a PromiseLike<void>.

I created theintern/intern#845 to track this.

@jason0x43
Copy link
Member

This slipped through before because the completed tutorial uses async/await rather than explicitly returning a Command chain. Since no value is explicitly returned in the async/await version of the test, the function implicitly returns a PromiseLike<void>.

@jason0x43
Copy link
Member

Once a new version of Intern is published (likely 4.1.3), the tutorial will be updated to use it. Until then, using await or tacking a .end() or .then(() => {}) to the end of a Command chain will make TS happy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants