Can't configure cypress in Laravel. cy.request () failed trying to load - laravel

Can't set up cypress in Laravel. I followed this example, but, unfortunately, everything breaks down at the initial stages. What could be wrong? First time I'm doing this.
Example I'm doing: https://github.com/laracasts/cypress.
Screenshots: Error 1 | Error 2
Env files: env.cypress | env | cypress.json

Related

Invalid testing environment specified: chrome

When run the this code got below error-
Invalid testing path
Like the error message states.
You have
'default', 'chrome-local'
environments available to you in your configuration file.
You will need to run the command npx nightwatch -e chrome-local like the user 'AutomatedTester' said.

TypeError: cy.findAllByText is not a function e2e-cypress-1 at Context.<anonymous> when run through docker-compose

1. I have added testing-library add-commands in support.js
2. I have created 2 jsconfig.js files to include cypress types
3. I have added comments in spec file to include cypress.
The tests works fine when run through cypress browser but when I run test in terminal using docker-compose command: docker-compose up --exit-code-from cypress
I get Type error Type Error: cy. find All By Text is not a function

Using different URLs for local and CI testing

I want to use Cypress to test locally and on CI at the same time. On CI, I would like to test a production version of my application, which has a different baseUrl than the local version, obviously. I am using the https://github.com/bjowes/cypress-ntlm-auth package to ause windows authentication for the CI, and to do so I have to call cy.ntlm line in my tests. I want to make an IF function that calls the cy.ntlm line ONLY if the baseUrl matches the production one. If the baseUrl is localhost then I would like the cy.ntlm line to be ignored. So my bottom line questions are, how do I let cypress know that I want to use 2 different URLs and how do I pack that into an IF statement? Thank you
You can check the baseUrl to conditionally call cy.ntlm,
const baseUrl = Cypress.config('baseUrl')! // use non-null assertion operator
const isLocal = baseUrl.includes('localhost')
if (!isLocal) {
cy.ntlm(...)
}
When using Typescript with Cypress you will get complaints because Typescript has no idea if you have set the baseUrl configuration or not.
You can overcome that by adding ! after getting the baseUrl value.
Ref Typescript - Non-null assertion operator
I separated the steps to make it clearer.
Assuming your cypress config file has the baseUrl. You can then update the baseUrl using the CLI during run time. For this create two different scripts with the staging and production URL's in your package.json like this:
"scripts": {
"test:local": "cypress run --config baseUrl=https://example.com/staging",
"test:ci": "cypress run --config baseUrl=https://example.com/production"
}
Then to run the scripts in CI use npm run test:ci and for local use npm run test:local.

Is it possible to include Vue Admin (Bulma) into Laravel?

I am pretty new to Vue.js and Js in general. I am using the Bulma.io CSS Framework and found the Vue-Admin Package which provides Vue Components in Bulma Styles.
I would like to use it but I am not sure how to require it. I tried to require a single Component like:
javascript
// resource/assets/js/app.js
Vue.component('sidebar', require('../../../node_modules/vue-admin/client/components/layout/Sidebar.vue'));
This throws the following Error in my Console:
ERROR in ./~/vue-admin/client/components/layout/Sidebar.vue
Module not found: Error: Can't resolve 'scss-loader' in '/Volumes/Data/Entwicklung/Workspace/Private/TheNewSumoAndPanda/node_modules/vue-admin/client/components/layout'
# ./~/vue-admin/client/components/layout/Sidebar.vue 5:0-169
# ./resources/assets/js/app.js
ERROR in ./~/vue-bulma-expanding/src/Expanding.vue
Module not found: Error: Can't resolve 'scss-loader' in '/Volumes/Data/Entwicklung/Workspace/Private/TheNewSumoAndPanda/node_modules/vue-bulma-expanding/src'
# ./~/vue-bulma-expanding/src/Expanding.vue 5:0-183
# ./~/buble-loader!./~/vue-loader/lib/selector.js?type=script&index=0!./~/vue-admin/client/components/layout/Sidebar.vue
# ./~/vue-admin/client/components/layout/Sidebar.vue
# ./resources/assets/js/app.js
I also tried to include some kind of an Autoloader and tried the following:
// resource/assets/js/app.js
require('../../../node_modules/vue-admin/client/app');
This throwed the following:
ERROR in ./~/vue-admin/client/app.js
Module parse failed: /Volumes/Data/Entwicklung/Workspace/Private/TheNewSumoAndPanda/node_modules/vue-admin/client/app.js Unexpected token (38:2)
You may need an appropriate loader to handle this file type.
| store,
| nprogress,
| ...App
| })
|
# ./resources/assets/js/app.js 9:0-53
This is the link to the Vue-Admin Package on GIthub:
https://github.com/vue-bulma/vue-admin
I hope you guys can help me?
Thanks David
I created an integration without laravel-mix: https://github.com/gazben/laravel-vue-admin
This solution uses the original build script, and the npm commands are wrapped by artisan commands. The output is symlinked to the appropriate directories.

PhantomJS can't find jasmine fixture

In Jasmine I am adding a fixture as below:
jasmine.getFixtures().fixturesPath = '/';
var fixture = readFixtures('test2.html');
setFixtures(fixture);
The tests run fine in the browser.
However, when I try to run the tests using PhantomJS I get the following error:
Network - Resource request error: QNetworkReply::NetworkError(ContentNotFoundError) ( "Error opening /test2.html: No such file or directory" ) URL: "file:///test2.html?_=123456789
It's as if PhantomJS cannot read the correct relative file path.
Is there anything I can do differently to get past this error?
For anyone else running into this, the trick is to call the actual url as opposed to a file, so instead of
$ phantomjs myTest.js path/to/my/SpecRunner.html
try:
$ phantomjs myTest.js http://localhost/path/to/mySpecRunner.html

Resources