I have some troubles running codeception coverage for Api tests, tests without coverage work just fine using config below:
Here is my api.suite.yml
class_name: ApiTester
modules:
enabled:
- \Helper\Api
- REST:
url: http://localhost/backend/web/
depends: PhpBrowser
part: Json
However when I run this with coverage i get following error:
[PHPUnit_Framework_Exception]
file_get_contents(http://localhost/backend/web/c3/report/clear): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
After seeing into the apache/error.log there is this:
PHP Fatal error: Uncaught Codeception\\Exception\\ConfigurationException: Path for output not specified. Please, set output path in global config in /var/www/html/vendor/codeception/base/src
I think its problem with PhpBrowser configuration, when I used Yii module instead of PhpBrowser there wasnt exception, however there was always error 404. I'm kinda stucked here. Thanks for help in advance!
Related
I'm trying to get Spartacus to work with SSR. When opening the default URL, http://localhost:4200, the storefront renders, as expected, but only after I clear the site data first. When I attempt to browse the storefront, API calls fail with a 504 (Gateway timeout). Chrome dev tools indicates the error is happening in the service worker. At this point, I'm wondering if I configured Spartacus incorrectly. When running Spartacus using yarn start rather than yarn serve:ssr, I can load the home page and browse the site normally.
OS: Ubuntu 16.04.6 LTS
Chrome Version: 73.0.3683.75
Node version: 11.15.0
Angular CLI version: 8.3.8
Yarn version: 1.19.1
ng new ssr-spartacus-app --style=scss
cd ssr-spartacus-app
ng add #spartacus/schematics --baseUrl https://localhost:9002 --baseSite cmssiteuid --pwa --ssr
rm src/app/app.component.html
echo "<cx-storefront>Loading...</cx-storefront>" > src/app/app.component.html
yarn build:ssr
yarn serve:ssr
Before running yarn build:ssr, I made following change to the app.module.ts file:
Before
context: {
baseSite: ['cmssiteuid'],
},
After
authentication: {
client_id: 'mobile_android',
client_secret: 'secret',
},
context: {
urlParameters: ['baseSite', 'language', 'currency'],
baseSite: ['cmssiteuid'],
},
I also set anonymousConsents to false. With this set to true, I was getting a lot of CORs errors.
If been scratching my head with this for a little while now and I'm hoping someone with more knowledge of Spartacus' inner workings can shed some light on why Spartacus is behaving this way with SSR.
I'm not sure that I can give you some certain recipe to fix the issue, obviously I need more details and logs relates to your problem, but still, based on my experience I can share with you some tips and tricks about how we should play with such issues (which relates to SSR).
Some set of theory which relates to SSR
https://angular.io/guide/universal (you can feel free to use Angular official documentation as a primary source, cuz Spartacus uses Angular OOTB features to make it works)
https://sap.github.io/spartacus-docs/server-side-rendering-in-spartacus/
https://enable.cx.sap.com/tag/tagid/spartacus (SSR related videos)
Practical approaches for debugging SSR
You should observe and analyze console output during starting your application in Node.js
You can use SSR configuration from example Storefront application (https://github.com/SAP/spartacus/tree/develop/projects/storefrontapp) like a starting point, cuz OOTB SSR works like a charm
Something from Spartacus team https://sap.github.io/spartacus-docs/how-to-debug-server-side-rendered-storefront/
Common set of theory to ensure that application has been configured correctly
SAP Commerce Cloud configuration for working with Spartacus https://sap.github.io/spartacus-docs/installing-sap-commerce-cloud/
Take a look on the guide https://sap.github.io/spartacus-docs/building-the-spartacus-storefront-from-libraries/ to ensure, that your frontend application has correct configuration
Double check your configuration which B2cStorefrontModule is using (here you can find an example project here https://github.com/SAP/spartacus/tree/develop/projects/storefrontapp)
Take a look on Network and Console browser tabs and try to resolve all errors
did you turn off PWA?
Turn PWA off.
As soon as Spartacus is installed in PWA mode, a service worker is installed, and it serves a cached version of index.html, along with the js files. This results in SSR being completely skipped. The following steps describe how to turn off PWA:
Check that there are no service workers registered in your app. If you do find any service workers, remove them.
Turn PWA off in your app module configuration, as follows:
StorefrontModule.withConfig({
backend: {
occ: {
baseUrl: 'https://[your_enpdoint],
},
},
pwa: {
enabled: false,
},
};
Rebuild your local Spartacus libraries by running the following command:
yarn build:core:lib
Build your local Spartacus shell app by running the following command:
yarn build --prod
Build the SSR version of your shell app by running the following command:
yarn build:ssr
Start Spartacus with the SSR server by running the following command:
yarn serve:ssr
If you are getting 504 after hitting the API service you need to check your API logs.
IF you have err log:
{"instant":{"epochSecond":1644915623,"nanoOfSecond":929833000},"thread":"hybrisHTTP1","level":"ERROR","loggerName":"org.springframework.web.servlet.DispatcherServlet","message":"Context initialization failed","thrown":{"commonElementCount":0,"localizedMessage":"Error creating bean with name 'cartEntriesController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultStockValidator' defined in ServletContext resource [/WEB-INF/config/v2/validators-v2-spring.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [de.hybris.platform.ycommercewebservices.stock.impl.DefaultCommerceStockFacade] to required type [de.hybris.platform.commercewebservices.core.stock.CommerceStockFacade]: Failed to convert value of type 'de.hybris.platform.ycommercewebservices.stock.impl.DefaultCommerceStockFacade' to required type 'de.hybris.platform.commercewebservices.core.stock.CommerceStockFacade'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'de.hybris.platform.ycommercewebservices.stock.impl.DefaultCommerceStockFacade' to required type 'de.hybris.platform.commercewebservices.core.stock.CommerceStockFacade': no matching editors or conversion strategy found","message":"Error creating bean with name 'cartEntriesController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultStockValidator'
You can try resolution:
Remove template extension ycommercewebservices extension from manifest.json, rebuild and redeploy with "Migrate Data" mode.
I am trying to set up WebStorm for one of the TestCafe project integrated with CucumberJS (Link: https://github.com/rquellh/testcafe-cucumber).
I am able to sort the debug configuration so far using WebStorm help, however, when I debug the project, it throws the following error to the console:
I am passing the following cucumber.js arguments:
--require testlab/**/step_definitions/*.js --tags #debug
And while I debug, I get the following error:
ReferenceError: testController is not defined
at World.<anonymous>
Test ignored.
Test ignored.
Failures:
1) Scenario: Searching for TestCafe on GitHub #
testlab\features\finAPIDemo.feature:6
× Given I open the GitHub page # testlab\step_definitions\github.js:5
ReferenceError: testController is not defined
I am expecting the debug to execute correctly, however, it is not working, the alternative I believe would be to write a js config and pass through as mentioned in the CucumberJS document page, however, I am not sure how to achieve that.
Any input or help will be appreciated.
This error only occurs when running cucumber with --tags #debug, and it's not specific to the IDE - you will face the same issue when starting your tests in terminal with node node_modules/cucumber/bin/cucumber-js --tags #debug:
node node_modules/cucumber/bin/cucumber-js --tags #debug
0 scenarios
0 steps
0m00.000s
E:\WebstormProjects\testcafe-cucumber\features\support\hooks.js:77
if (testController.testRun.lastDriverStatusResponse === 'test-done-confirmation') {
^
ReferenceError: testController is not defined
at Timeout.checkLastResponse [as _onTimeout] (E:\WebstormProjects\testcafe-cucumber\features\support\hooks.js:77:9)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
I'm not sure why you need this option... There are no scenarios marked with #debug in your project, as far as I can see.
I'd suggest using a standard Cucumber.js run configuration for debugging. It works fine for me - tests are run, and breakpoints are hit:
You need to add the #debug directive for the scenario that you want to debug.
See the full setup in this help topic.
I would recommend using cucumber profiles and call that profile instead of using cli commands. Looking at the error you are receiving it looks like you are missing more required directories such as a custom world directory?
Under the hooks.js I have updated the import statements with const assignment and that worked for me:
Replaced:
'import errorHandling from "./support/errorHandling.js";\n' +
'import testControllerHolder from "./support/testControllerHolder.js";\n\n' +
with
'const errorHandling = require("./support/errorHandling.js");\n' +
'const testControllerHolder = require("./support/testControllerHolder.js");\n\n' +
So im having this Problem and i can't find any solutions, anywhere.
I am trying to check: after the a URL redirect the ResponseCode is 200...which i is because i can see it in the Console.
How every when running this code
public function responseCodeWifi(\AcceptanceTester $I, REST $rest)
{
$I->wantTo('Check redirect for de/wifi-welcome');
$I->amOnPage('/de/wifi-welcome');
$I->seeInCurrentUrl('/wifi-welcome');
$rest->seeResponseCodeIs(200);
}
i get the following error in my Shell
[Error] Call to a member function getInternalRequest() on null
Im using chrome and selenium.
EDIT:
using
use AcceptanceTester;
use Codeception\Util\HttpCode;
use Codeception\Module\REST;
REST module can't inspect responses of WebDriver module.
If your Acceptance suite used PhpBrowser module, you could use REST module to inspect responses by making it dependent on PhpBrowser:
modules:
enabled:
- PhpBrowser
- REST:
depends: PhpBrowser
And call seeResponseCodeIs in you test code as
$I->seeResponseCodeIs(200);
I'm working on a CakePHP 3.x project on a Vagrant VM. My project has a single Test for a Controller. Project was setup using composer and phpunit is installed in vendor directory.
Running ./vendor/bin/phpunit Tests throws the following error:
[vagrant#devenv-lamp ~/www]$ ./vendor/bin/phpunit Tests
PHP Fatal error: Interface 'PHPUnit\Framework\TestListener' not found in /vagrant/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php on line 30
Fatal error: Interface 'PHPUnit\Framework\TestListener' not found in /vagrant/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php on line 30
I tried running PHPUnit for a single Controller as well - with the same results...
[vagrant#devenv-lamp ~/www]$ ./vendor/bin/phpunit tests/TestCase/Controller/QuestionsControllerTest.php
PHP Fatal error: Interface 'PHPUnit\Framework\TestListener' not found in /vagrant/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php on line 30
Fatal error: Interface 'PHPUnit\Framework\TestListener' not found in /vagrant/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php on line 30
I'm very new to PHPUnit and am running into a wall even without taking off the ground. Any help here will be greatly appreciated.
It looks like autoloading is not set up correctly.
In your phpunit.xml you need to specify a bootstrap file. This can either be a custom script based on your project or in some cases it's as easy as using composer's autoload.php:
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd"
bootstrap="vendor/autoload.php"
>
...
</phpunit>
I'm using jasmine-rails-0.4.5 and devise-2.2.3 in a standard rails-3.2 app. When I run bundle exec rake spec:javascript, in order to run the jasmine specs, I'm getting the following message: "Jasmine runner at '/specs' returned a 302 error: Found"
Since I'm using devise any request against the server that is not authenticated yet, it's being redirected to the log-in page. So far so good, that is the expected behavior from devise, but jasmine-rails need to access the /specs url in order to run the tests, so when it tries to access this it, it's getting this error: "Jasmine runner at '/specs' returned a 302 error: Found"
In my routes.rb file I added this line: "*mount JasmineRails::Engine => "/my_specs" if defined?(JasmineRails)*"
Any clue?
Thanks
This is what it fixed the issue (I did an upgrade for a newer version):
update your js libraries
get rid of all the entries under the section "src_files" except for "assets/application.js" on the spec/javascripts/support/jasmine.yml file
Add this file:
+++ b/spec/javascripts/support/jasmine_helper.rb
## -0,0 +1,13 ##
+#Use this file to set/override Jasmine configuration options
+#You can remove it if you don't need it.
+#This file is loaded *after* jasmine.yml is interpreted.
+#
+#Example: using a different boot file.
+#Jasmine.configure do |config|
+# #config.boot_dir = '/absolute/path/to/boot_dir'
+# #config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
+#end
+#
+
+Rails.application.config.action_controller.asset_host = "//localhost:8888"
+Rails.application.config.base_url = ENV['BASE_URL'] || "http://localhost:8888"
Get rid of this file: spec/javascripts/support/jasmine_runner.rb
Hope this helps