Elixir TDD tests only execute when a test file is saved - laravel

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.

Related

Does Cypress support pre-execution checks?

I run Cypress from the terminal using an npm script. I would like to run a series of checks before any tests in any spec are executed (e.g. to ensure env variables are set as expected).
If any check fails, I'd like to log some debug info and Cypress to mark each spec as failed.
Is something like this possible without having to have a custom script that executes before Cypress is started?
I've played around with the support file, but logging to the terminal and failing all test specs seems problematic.
Yes you can use Before Run API
on('before:run', (details) => {
/* ... */
})

Cypress browser refreshes browser on changing test file

I am using Cypress for end to end testing, and I would like to be able to see all run test suites, in the browser, even after they are run. Currently, after each test suite is completed (test which are stored in separate files), the browser reloads and I cannot see previously run tests, and after the final test suite, the browser closes. Is there an option to change this behavior so that I can run all test files, have all the results visible in the browser and that the browser doesn't close at the end?
I am currently running tests using this command: ./node_modules/.bin/cypress run --headed --spec 'cypress/integration/tests/*'
where /tests is the folder where I currently have my files.
I have added --no-exit but in this case cypress doesn't move to the next test file and only the first one runs.
A workaround solution could be to generate reports with Mochawsome, for each Test Spec, and then merge and view those rendered reports. The reports will contain the results from the tests, test bodies, any errors that occurred and some other bits of information.
If you read through the page in the link it shows you how to generate individual reports then combine them together, and then render them as HTML. These can then be viewed in the browser.
This command can be used to install what's needed npm install --save-dev mochawesome mochawesome-merge mochawesome-report-generator
and then add the Reporter configuration to the cypress.json:
{
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/results",
"overwrite": false,
"html": false,
"json": true
}
}
Keep in mind that it may not give you the level of detail that is contained in the Cypress Dashboard in the browser, for example, what was yielded from a request.
Cypress has a lot of possible command with a lot of possible config too.
Read this.
And if you use npm just run like this :
npm run cypress:open
and in your package.json :
"scripts": {
"cypress:open": "cypress open"
}

Debugging Protractor tests using Gulp tasks with WebStorm

I run my Protractor tests using a gulp task and I pass all the parameters in the gulp task like:
gulp protractor-integration --useProxy=true --baseUrl=http://10.222.25.18:81 --apiUrl=10.124.22.213:8080 --suite=tests
I have tried to set up a configuration in WebStorm for Gulp and pass all the parameters there. When I hit run the correct tests are executed.
When I put a break point and hit debug the tests are executed and WebStorm does not stop at the break points.
Gulp Configuration in WebStorm for Debugging is not working. Sample Picture
Gulp run configuration is not supposed to be used for protractor tests debugging - it was designed to run/debug Gulp tasks.
To debug certain Node.js application, like Protractor tests, you need to make sure that debug arguments (--debug-brk/inspect-brk) are passed to Node process that starts the application. In your case, the application is spawned as a child process by Gulp. The IDE can only pass debug args to the main process (Gulp), that's why only Gulp tasks themselves will be debugged and not the child processes started by these tasks.
If you still prefer using Gulp to start your tests instead of using the dedicated Protractor run configuration, make sure that protractor process is started with --debug-brk/inspect-brk .
Do do this, you need changing node_modules/gulp-protractor/index.js accordingly. For example, modifying childProcess.fork call as follows will start Protractor with --inspect-brk=5860:
child = childProcess.fork(getProtractorCli(), args, {
stdio: 'inherit',
env: process.env,
execArgv: ['--inspect-brk=5860'] //added line
}).on('exit', function(code) {
...

Codeception functional test not running, but no error

I am following the Build Larabook from scratch Laracasts tutorial (building a Facebook-like app).
In lesson 14, we implement the "sign in" feature.
Problem, when I try to run my functional test (that has been running smoothly so far), I get nothing, not even an error message:
vagrant#homestead:~/larabook$ vendor/bin/codecept run functional
Codeception PHP Testing Framework v2.0.7
Powered by PHPUnit 4.3.4 by Sebastian Bergmann.
Here is the content of my SignInCept.php:
$I = new FunctionalTester($scenario);
$I->am('a Larabook member');
$I->wantTo('login to my Larabook account');
$I->signIn();
$I->seeInCurrentUrl('/statuses');
$I->see('Welcome back!');
I tried to log out of my Vagrant vm but kept getting the same issue.
Is it possible that I broke something while updating some files?
Check carefully your signIn action in FunctionalHelper for any syntax errors. Tests fail like this without showing any errors when there is something wrong in there.
Late answer but do not use composer exec. Use the full path to codeception.
For example:
**vendor/bin/codecept run**

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