I was looking for a way to make failure messaging more descriptive in Jasmine and found this functionality https://jasmine.github.io/api/edge/matchers.html#withContext
So I try it in my Protractor framework like this
expect(true).withContext("something else").toBe(false);
Run the test and get error - Failed: expect(...).withContext is not a function
This feature was implemented since Jasmine 3.3.0, so I checked my package.json and see "jasmine": "^3.3.1", and package-lock.json has
"jasmine-core": {
"version": "3.3.0",
Any ideas what is wrong?
Just got an answer from Jasmine team on the GitHub stating
Protractor uses jasminewd wrapper which uses Jasmine 2.x. If you want
to use Jasmine 3.x, you can use Protractor 6.0, that has been released
recently. In older versions the newest features of Jasmine, like
withContext function, async hooks (e.g. onSpecDone) are not available.
Besides the difference in Protractor version I found out that my grunt task runner has been using grunt-protractor-runner v5.0.0 which used protractor 5.4.2. So I had to open protractor.conf.js directly with protractor.
Related
We do not use the Component Testing feature in Cypress, which was introduced in version 10.x and above. Its an additional burden to close it every time before we land into the test runner.
You can use the --e2e flag when running Cypress via command line to launch directly to the end-to-end test suite. Assuming you're using npm, that would be:
npx cypress open --e2e
If you have a package.json file where you store your scripts, you can modify that script as well.
...
"cypress:open": "npx cypress open --e2e",
...
npm run cypress:open
I am using angular2-datatable version 0.6.0 in my angular application which used
Angular Version 2.
We upgraded Angular to use 13.2.0 recently, the application build and compiles successfully.
But I see some console error when I did ng serve.
The errors are related to angular2-datatable saying that is is not compatible with Ivy.
The error is shown below.
Error: node_modules/angular2-datatable/lib/DataTableModule.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of XXXXXXX, but could not be resolved to an NgModule class.
This likely means that the library (angular2-datatable) which declares DataTableModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
I see the latest version of angular2-datatable is 0.6.0.
I tried changing "aot": true or false in Angular.json file and also modified "enableIvy" property in tsconfig.json to true or false, nothing seems to clear those errors.
Any clue on how to resolve this..
In angular.json setting both buildOptimizer and aot properties to false did the job for me.
Any contract I successfully build that has a dependency to elrond-wasm 0.19.1 fails to deploy
Is there any known issue regarding this or am I the only one facing this?
Trying to build on the older 0.18.2 works but a lot of the contract code has to be changed in order to achieve a build.
Most examples I have tried to build and deploy from the Elrond Github Rust examples repository fail when deployed with the same error.
Although the one found at https://github.com/ElrondNetwork/ping-pong-smart-contract that is using these dependencies:
[dependencies.elrond-wasm]
version = "0.18.2"
features = ["derive"]
[dependencies.elrond-wasm-node]
version = "0.18.2"
optional = true
[dev-dependencies.elrond-wasm-debug]
version = "0.18.2"
works great. Build and deploy work flawlessly.
If you are trying to deploy on the devnet this will fail because it hasn't been updated to 0.19 yet, so you still have to use 0.18.x there.
Also note that 0.19.1 wasn't officially released yet, so that will most likely fail on mainnet and devnet as well.
So either way the solution as you have already described is to downgrade your elrond-wasm versions to 0.19.0 or 0.18.2, depending on the net on which you want to deploy.
I have an Angular flavoured Nativescript project.
After follwoing the steps from https://docs.nativescript.org/tooling/testing/testing I encountered the following error:
ERROR in ./src/tests/example.ts Module build failed (from
../node_modules/#ngtools/webpack/src/index.js): Error:
/home/..../src/tests/example.ts is missing from the TypeScript
compilation. Please make sure it is in your tsconfig via the 'files'
or 'include' property.
The steps I did:
tns test init - enter on jasmine
npm i #types/jasmine --save-dev
started my android emulator
tns run android
You can see that the generated example test file does not work, but I did not read anything on the site about modifying the tsconfig.json.
One possible solution is to ... do exactly as the error message says.
after inserting this:
"include": ["src/tests/**/*.ts"]
to the tsconfig.json (or tsconfig.tns.json), the tests run without a problem.
Although I think this means, this file gets included in every build (not just test runs) so not the best solution yet. Including this line only in the tsconfig.spec.json did not help either, it seems I have to prepare a different build for production which will not include this.
We have a set of Jasmine tests that run successfully in the local web server. http-server.
We would like to run these tests from the command line during the TeamCity build process without having to start a webserver.
Opening the html file with chrome using --disable-web-security flag results in
Failed to load module script: The server responded with a
non-JavaScript MIME type of "". Strict MIME type checking is enforced
for module scripts per HTML spec.
Probably because script references with type="module" in the SpecRunner.html file
<script src="../src/js/App/app.js" type="module"></script>
Jasmine tests are coupled to DOM/jQuery so that they need to be run in a browser. The SpecRunner html page includes script references with type="module".
How can we run these tests during a TeamCity build and fail the build if there are any test failures?
Thanks.
Here's my solution. We are already using jest for react tests and jest docs say
If you are using Jasmine, or a Jasmine like API (for example Mocha),
Jest should be mostly compatible, which makes it less complicated to
migrate to.
npm install jest puppeteer jest-puppeteer http-server
jest: To run the tests using Jasmine API
puppeteer: To run tests in headless chrome browser
http-server: Local webserver to navigate to the jasmine spec runner page
jest-puppeteer: To configure starting the local server before running the tests and stopping it afterwards
Add jest-puppeteer-config.json to start the server like this
Jest Puppeteer integrates a functionality to start a server when
running your test suite. It automatically closes the server when tests
are done.
Add a jest-puppeteer test to navigate to Jasmine SpecRunner page and assert that there are no failures.
Update your jest configuration docs
Create npm script to a run jest test that in turn runs Jasmine tests in the browser.
At this point, one should be able to run browser Jasmine tests from the command line locally or on the build server.
Here is a screenshot that shows the files and test run results both locally and on TeamCity.
How can we run these tests during a TeamCity build and fail the build
if there are any test failures?
This solution enabled us to restore around hundred legacy browser-coupled Jasmine tests as part of the build with minimum effort (did not have to update the tests).
Feel free to suggest alternatives.