electron-userland / electron-userland/spectron

Examples recommend using chaiAsPromised but it has problems with some promises.

Open
#71 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
1.7k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

chaiAsPromised doesn't properly handle rejections, and constantly reports true for some `spectron` methods when using some Promised methods. For example:

``` js
it("should be true", function() {
let val = this.app.electron.remote.getGlobal("appConfig").then(v => { return v.val })
assert.eventually.equal(
val, true
)
})
```

Always returns true for us, and never actually causes an assertion failure because there was a rejection with the object having an error. We could catch it, but then what is the point of chaiAsPromised at that point?

---

I propose the documentation also recommend a better way to deal with promises if they are using ES7.

``` js
it("should be true", async function() {
let config = await this.app.electron.remote.getGlobal("appConfig")
assert.equal(
config.val, true
)
})
```

If this is acceptable, I'm happy to send a pull request.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no documentation file or test. Start by locating the examples that recommend chaiAsPromised and reviewing how Spectron promise-based tests are documented. Done means the relevant guidance presents the proposed async/await approach, or clearly explains the supported alternative.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation, testing-qa
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.