CakePHP 4 Error running PHPUnit with Fixture: UnxepectedValueException; Could not find fixture - terminal

Running a PHPUnit controller test in Visual Studio Code terminal receives error in testIndex:
UnexpectedValueException: Could not find fixture app.Questions.
C:\server\www\host\vendor\cakephp\cakephp\src\TestSuite\Fixture\FixtureHelper.php:90
C:\server\www\host\WebBuilderLogin\vendor\cakephp\cakephp\src\TestSuite\Fixture\TruncateStrategy.php:51
C:\server\www\host\WebBuilderLogin\vendor\cakephp\cakephp\src\TestSuite\TestCase.php:301
C:\server\www\host\WebBuilderLogin\vendor\cakephp\cakephp\src\TestSuite\TestCase.php:249
The Fixture is present in the Fixture directory which is in the tests directory.
tests
|-Fixture
|=ArticlesFixture.php
|-TestCase
|-Controller
|=ArticlesControllerTest.php

Related

Getting the error "Cannot find module './commands'" while trying to run cypress tests

When I'm trying to run cypress test I'm getting this error:
The following error originated from your test code, not from Cypress.
\> Cannot find module './commands'
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.
I was expecting my tests to run, and I've tried to create an index.js in the support folder with:
import './commands'
Cypress.on('uncaught:exception', (err, runnable) => {
return false;
})
But that doesn't seem to work.
When I had this issue it was because I tried to import from the wrong file.
Instead of importing in the test file, commands should be imported into /cypress/support/e2e(.js|.ts) file.
Ref Custom Commands
We recommend defining queries is in your cypress/support/commands.js file, since it is loaded before any test files are evaluated via an import statement in the supportFile.
That way they are available in any test that requires them. This is because the /cypress/support/e2e.js file is automatically integrated into the start of any and all test runs.

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

In test runner cannot see tests in newly created folder - cypress

I created new folder 'apitests' in cypress project and created a JavaScript test file in it. It does not show up in the test runner.
I have used the default configuration in cypress.json as specified in Cypress documentation
"testFiles": "**/*.*",
I expected my new folder 'apitests' and JavaScript test file to show in the test runner. Here is the end result.
Here is the file structure.
You've put your apitests folder directly in cypress/, while Cypress by default looks in cypress/integration/ folder.
You can change that by using integrationFolder config option, but I'd personally just keep the spec files in cypress/integration as is the default.
I had to add this to cypress.config.js:
module.exports = defineConfig({
e2e: {
specPattern: [
'cypress/e2e/*.js',
'cypress/e2e/**/*.js'
]
}
});
I had it initially, but removed it, to hope that Cypress would automatically find all my tests. But that resulted in new tests not being added to the test-runner.
My Cypress-version: 11.x.x (and I updated to 12.0.2 as a debugging attempt).
The solution was found in the Cypress-documentation for config.
You've put your apitests folder directly in cypress/, while Cypress by default looks in cypress/integration/ folder.
You will get an idea about it

Elixir TDD tests only execute when a test file is saved

I have a fresh installation of Laravel 5.1, and am trying to run automated tests using Elixir. According to documentation, I can run gulp tdd and have my tests execute automatically each time a file is saved. I have the initial ExampleTest.php which has this test:
public function testBasicExample()
{
$this->visit('/')
->see('Laravel 5');
}
This test asserts if the default welcome.blade.php file shows Laravel 5. Each time when I save the ExampleTest.php file, the automated tests do execute, and that's great. But when I change and save the welcome.blade.php file, the tests do not execute automatically.
Is this the desired behaviour or not? If not, what could be causing it?
By default elixir comes with two tasks for your test suites. One for phpunit and the other for phpspec, in your gulpfile phpUnit method is called on the mix object for phpunit test suite.
mix.phpUnit();
mix.phpSpec();
And then you need to type Gulp watchfrom terminal.

CLI testing with Jasmine / PhantomJS

Running yeoman server:test opens Jasmine in my browser and says that my test has passed. Now I want to try the same, but without a browser - using PhantomJS on the CLI. Unfortunately, running yeoman test only throws a:
Running "jasmine:all" (jasmine) task
Running specs for index.html
>> 0 assertions passed in 0 specs (0ms)
Why doesn't it find any tests, even though everything is included in my test/index.html and works pretty well using yeoman server:test?
I used yeoman init jasmine:app --force over my project and adjusted the Gruntfile.js as described here. It looks like that:
...
// headless testing through PhantomJS
jasmine: {
all: ["test/**/*.html"]
},
...
// Alias the `test` task to run the `jasmine` task instead
grunt.registerTask("test", "jasmine");
...
Note: My tests are written in CoffeeScript.
After some research I found out that PhantomJS is not able to find the files at the same location as ´yeoman server´ or yeoman server:test does.
I precised my question in another thread: Running tests in both headless and browser

Resources