ng2-bootstrap. Errors during e2e tests - ng2-bootstrap

Trying to run e2e tests for ng2-bootstrap and have a couple of issues. Interested if this is jut me or not.
Here's what I'm doing:
Download the latest from
https://github.com/valor-software/ng2-bootstrap
run npm-install
run npm run build
run npm run link
and finally run nmp run e2e
On the first run I got an error: SpecReporter is not a constructor which I was able to fix by replacing const SpecReporter = require('jasmine-spec-reporter'); in protractor.conf.js to const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
But than there's another error: Cannot find namespace 'webdriver' which I can't figure out how to fix.
So if someone could just repeat these steps above an let me know if you're getting the same results I would really appreciate it.
I have created an issue on github about this: https://github.com/valor-software/ng2-bootstrap/issues/1665

try import * as webdriver from 'selenium-webdriver';

Related

CypressError cy.visit() failed trying to load https://example.cypress.io/todo

i created cypress project
for that i run npm init -y to generate package.json file then npm i cypress to create a cypress project.
then opened it via npx cypress open
here i'm getting this error [20928:0420/171517.057:ERROR:command_buffer_proxy_impl.cc(125)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
but the cypress has opened.
when i try to run the default test case todo.spec.js
i'm getting this error i searched about this error for a day. i didn't get any solution for this.
can anyone guide me how to resolve this.
it's because of a proxy issue.
in my organization, I should write the test cases only in the localhost/org., server.

Cannot find module - Error when running tests on react project

When i run yarn test locally on my React project i get this error (project is created with Create react app):
Cannot find module <project_directory>node_modules/babel-preset-react-app/node_modules/#babel/runtime/helpers/interopRequireDefault
Everything was normal and after adding react-responsive package, my tests started failing like this.
Even though they show that they fail, when i choose to run only failed tests, they don't run again. It's like they failed in their own way but not concerning the test process.
On the side note, when my tests run on CI/CD pipeline, they work with no problem.
After taking into consideration that CI/CD pipeline test run succeeds, i got to thinking that it could have to do something with my local environment.
Solution is to first clear cache in tests and than run tests again:
yarn test --clearCache
And that run
yarn test
NPM variant:
npm test -- --clearCache
And everything works fine now.
I found out on this issue that regards on a similar error but for a different module.
This answer gave me a solution
Issue in on create react app repo

How do I resolve "react-snap error on running build"

I installed react snap to my react project and then when I run build it doesn't crawl each page instead shows some error. Previously it was working fine, but don't know what happened now. this is the error which I am getting on running npm run build It would be nice if I could get a quick solution.

Running Jest tests on Appveyor from powershell

I am trying to run my Jest tests on Appveyor. I am using the asp.net core template for a react app (which uses create-react-app). When I run the tests locally (with npm run test) the tests run fine, I see PASS src\App.test.js with a run-down of the tests that have passed.
In Appveyor, however, an error is thrown from the console, causing my build to fail. The error message is PASS src\App.test.js. So it would seem an error is being emitted from the run somehow, despite the fact it seems to actually be passing. I checked and $LASTEXITCODE is -1
App.Test.js
it('Runs tests', () => {
expect(true).toBeTruthy();
});
Appveyor.yml
test_script:
- ps: .\build\appveyor\js-tests.ps1
.\build\appveyor\js-tests.ps1
($env:CI = $true) -and (npm run test)
I'm setting the CI environment as this prevents the tests from using "watch". the js-tests script does some other stuff with sorting file locations and a bit of logging etc, but I don't think that is relevant giving the message comes back as a passed test.
Npm sometimes writes normal output to stdErr, which custom PowerShell host on AppVeyor treats as error. Solution is to run those tests in CMD. So wrap them int .cmd file and run with - cmd: prefix.
An alternative to #ilyaf 's answer was to use jest-silent-reporter, which does not give an output when tests pass. This works for the same reason ilyaf's answer does, because npm writes output to stderr, not writing anything solves it.
to install:
npm install jest-silent-reporter --save-dev
in your package.json
"scripts": {
"test": "react-scripts test --env=jsdom --reporters jest-silent-reporter",
},
note i define the reporter here.
I'd also recommend adding a log after calling npm test so your logs have some confirmation that the thing has run.

Newbie to Selenium E2E with React

I created a boilerplate React project, packages.json has the usual suspects:
prestart
start
list
test
etc.
I am using Selenium for my E2E framework. I have the following test:
it('should launch a browser', () => {
const By = webDriver.By;
let driver = new webDriver.Builder()
.forBrowser('chrome')
.build();
// verify Continue button exist on page
driver.navigate().to('http://localhost:3000').then(() => driver.findElement(By.id('submitButton')).getAttribute('value'))
.then(buttonValue => expect(buttonValue).toEqual('Continue'));
});
If I do npm start, my site launches and my E2E launches an additional Chrome browser and navigate to my running site: localhost:3000. The test succeeds.
My question is, how do I run my E2E separately, without the need to my site side by side using npm start.
I am newbie to React and Selenium, in case I am missing a lot of information on this post, I apologize in advance.
Well, since you didn't find the time to update the question information with the NPM "scripts" object, then I'll try to give it a shot in the dark.
First of all, due to your wording, I can interpret your question two ways:
a.) you want to run your E2E tests separately, w/o your server running (which is started via npm start);
b.) you want to run your E2E tests via npm start, without triggering your server from starting;
a.) If you want to run your scripts separately, seeing as you are using Mocha, then you can trigger them via: ./node_modules/.bin/mocha <pathToTests>/<testFile>.
Now, since you stated in your question that you're using npm test script, then that should be the best switch to bind your E2E tests execution to:
package.json (Scripts object):
"scripts": {
"test": "mocha --reporter spec <pathToTests>/<testFile>",
"start": "node <yourServerName>.js"
},
Please note that mocha <pathToTests>/<testFile> is equivalent to ./node_modules/.bin/mocha <pathToTests>/<testFile>, because NPM looks for binaries inside node_modules/.bin and when Mocha was installed, it installed it into this directory.
Note: Many packages have a bin, or .bin section, declaring scripts that can be called from NPM similar to Mocha. If you want to find out what other binaries you can run that way, just issue a ls node_modules/.bin.
b.) In this care, I think your issue might be due to NPM defaulting some script values based on package contents. Specifically, if you have a server.js file in the root of your package, then npm will default the start command to server.js.
So if you're starting your E2E tests via npm start, having this ("start": "mocha <pathToTests>/<testFile>") in your package.json and there is a server.js file in the root of your package, then npm will default the start command to node server.js.
In which case, you could either move your server script to another place in the project, or change the switch you're using to trigger the E2E tests (see section b.)).
Hope this solves your problem and if not, looking forward for that package.json "scripts" object so we can really see what's up. :)
Cheers!

Resources