Comments (23)
I see what you mean, but I'm not able to reproduce the issue on a MacOS and don't have access to a Windows machine at the moment. There are several things at play here, so maybe this will help you find out more about the root cause of the problem:
chai-as-promised
is a JavaScript library, so it needs external type definitions -@types/chai-as-promised
@types/chai-as-promised
augments the interface of the standard chai assertion to add theeventually
property
For chai-as-promised
to work with chai
, we need to:
- register it
- but we also need to make the IDE aware of the type definitions (as far as IntelliJ or VisualStudio are concerned, it's still regular Chai that they're providing intelli-sense for, that's why they complain about the property not being there)
My IntelliJ is configured to use the local TypeScript module and the tsconfig.json
file that ships with the tutorial:
I'm guessing that VS might need similar sort of configuration.
Perhaps VS has a setting to enable TypeScript language service?
from serenity-js.
Visual Studio Code seems to work fine, it seems to be the just in time compilation when it loads the web page or test within? I only used VS code to load the project just to see if it gave me any clues. The error happens when I run "npm test".
One other thing, I can see in the transpiled javascript the files from screenplay, but not in features?
from serenity-js.
Hey @johnlister @marktigno, I've just updated the tutorial, would you mind checking if that helps to solve the problem you noticed?
from serenity-js.
@jan-molak will do, I'll apply the latest updates on my local machine and verify the fix.
from serenity-js.
Hello @jan-molak, I've verified the fix and now it's working. However there's a separate issue when running the test. It seems it's getting a timeout issue after it's launch. But I've made another fix on it so it won't happened again.
Thanks! :)
from serenity-js.
Hi @rollrodrig,
At first glance, the reason behind the compiler error seems to be the mixup of different import styles.
Instead of saying:
import chai from 'chai'; var chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); let expect = chai.expect; let assert = chai.assert;Try:
import chai = require('chai'); import chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); const expect = chai.expect;The
var chaiAsPromised = require('chai-as-promised')
syntax tells the compiler that the module in question does not have any type definitions. Because of that,chai-as-promised
types are never registered, and the compiler correctly complains thatProperty 'eventually' does not exist on type 'Assertion'
, as botheventually
andrejected
are defined in thechai-as-promised
module which has been ignored.Hope this helps!
Jan
Thanks !!
Finally i solved the problem.
I would like to share the link.
https://stackoverflow.com/a/55855503/5708097
from serenity-js.
Thanks for reporting this, that's interesting.
Are you seeing this problem on a fresh copy of 2-reports
?
from serenity-js.
Actually I'm also experiencing the same error when I'm creating my scripts using Screenplay pattern. I just follow what is instructed on the tutorial but that TSError (2339) always appearing.
from serenity-js.
Sorry to hear that, what platform are you on? OS/node version?
Also, @johnlister and @marktigno would you be able to push a code sample to github so that I can try to reproduce the problem?
I think this might be caused by the @types/chai-as-promised
not getting loaded for some reason.
from serenity-js.
@jan-molak Here's what I used on my machine:
OS: Windows 10
Node: 6
I used npm manager to pull a fresh copy of the packages, but the problem is on the chai-as-promise part where it says the "eventually" is not recognized as part of 'Assertion'. I check the exports from the 'expect.ts' file on the sample project to see if the references are properly set, but it seems there is something missing on it.
from serenity-js.
Windows 10, fresh install of Node 6.10, updated to latest NPM (4.4). clone the tutorial and switch to "2-reports" branch
npm install followed by npm test. This is with unmodified code in the branch.
I haven't installed any npm modules globally - oddly visual studio code doesn't complain about eventually, but does note that expect returns the base Assertion class and not a PromiseAssertion. I'm reasonably new to typescript, but is this a types issue in how it interprets the response of expect?
from serenity-js.
Here's my sample screenshot:
from serenity-js.
I did a little play around on the "node_modules/@types/chai/index.d.ts" and place the line "eventually: Assertion;". Now it recognized the keyword but it gives now a different error shown here:
from serenity-js.
I found the solution here:
jan-molak/serenity-js-fast-track-demo@1b545fa
from serenity-js.
Perfect, works for me. Oddly google didn't bring that up, but I did spot something similar in another project. I incorrectly assumed that both forms were identical in function - clearly not.
from serenity-js.
No problem at all! The todomvc.com website can be slow at times, so setting the timeout will definitely help :-)
from serenity-js.
Hi, the fix you've put in place works, but there is an issue on the dependency of gherkin. It now fetches v4.1.1 of gherkin (via cucumber) which when I run it causes the following issue:
E/launcher - Error: TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.relative (path.js:539:5)
at C:\src\js\serenity-js-e2e-testing-sample\node_modules\serenity-js\src\serenity\reporting\serenity_bdd_reporter.ts:89:38
Forcing gherkin to be v4.0.0 works - it looks like the only difference is gherkin has updated to using node 7 - I suspect the path api has changed as I'm currently running node 6.10
from serenity-js.
Thanks @johnlister, @metrophos has just raised that under #32
from serenity-js.
Hello @jan-molak!
I've updated the package.json based on what is posted on issue #32 and it works perfectly. Thanks!
from serenity-js.
Perfect, thanks for the update :-)
from serenity-js.
I am trying to use Chai Promise test but it show an error
I am using docker.
Here a simple function
let funcPromise = (n) => {
return new Promise((resolve, reject) =>{
if(n=="a") {
resolve("success");
}else {
reject("Fail")
}
})
}
simple test
import chai from 'chai';
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
let expect = chai.expect;
let assert = chai.assert;
it('connect: test promise', (done) => {
let func = funcPromise("a");
expect(func).to.eventually.equal("success"); // dont work
expect(func).to.be.rejected; // dont work
})
Error on terminal
FileTest.spec.ts:43:25 - error TS2339: Property 'eventually' does not exist on type 'Assertion'.
storage/database/MongooseEngine.spec.ts:44:35 - error TS2339: Property 'rejected' does not exist on type 'Assertion'.
from serenity-js.
Hi @rollrodrig,
At first glance, the reason behind the compiler error seems to be the mixup of different import styles.
Instead of saying:
import chai from 'chai';
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
let expect = chai.expect;
let assert = chai.assert;
Try:
import chai = require('chai');
import chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const expect = chai.expect;
The var chaiAsPromised = require('chai-as-promised')
syntax tells the compiler that the module in question does not have any type definitions. Because of that, chai-as-promised
types are never registered, and the compiler correctly complains that Property 'eventually' does not exist on type 'Assertion'
, as both eventually
and rejected
are defined in the chai-as-promised
module which has been ignored.
Hope this helps!
Jan
from serenity-js.
Cool, glad we could help 👍
from serenity-js.
Related Issues (20)
- Serenity/JS docs should be more Windows-friendly
- Serenity/JS REST should automatically detect proxy configuration
- Serenity/JS should allow sharding tests for better scalability in large CI systems HOT 1
- Serenity/JS should ...update the test results and attach a copy of serenity report in JIRA/XRAY.
- integration with Jira/XRAY doesnt work as it doesnt update result or attach report. HOT 1
- Serenity/JS should offer a more intelligent strategy to take photos of failures HOT 7
- Serenity/JS should provide a way to pass custom scroll options to the `scrollIntoView()` method HOT 10
- Some report customization properties in `serenity.properties` not picked up HOT 1
- Running tests from serenity-js-cucumber-webdriverio template on Windows gives ERR_UNSUPPORTED_ESM_URL_SCHEME error HOT 1
- Serenity/JS should announce tags on playwright test name automatically
- Step definations not being inferred when using ESNext modules
- Serenity/JS should allow for uploading files
- Serenity/JS should support drag and drop interactions
- Serenity/JS should make it easier to configure CA certifactes for Axios client used with the CallAnApi ability
- Upgrading to Serenity Js3 HOT 1
- Serenity/JS should allow to hide sensitive information in report HOT 5
- Serenity/JS should allow to attach files or other attachments to test cases and show them in the html report HOT 1
- Serenity/JS should contain templates with Selenium HOT 1
- Serenity/JS docs should explain how to set window size when using Playwright without Playwright Test
- Serenity/JS should have a "Community" page
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serenity-js.