Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dalek callback or custom functions #154

Open
dezhavi opened this issue Mar 25, 2015 · 1 comment
Open

dalek callback or custom functions #154

dezhavi opened this issue Mar 25, 2015 · 1 comment

Comments

@dezhavi
Copy link

dezhavi commented Mar 25, 2015

I'm using dalek. I want use custom function after the creation of an screenshot. Example:

var fs = require('fs');
module.exports = {
'Amazon does its thing': function (test) {
test'open';
test.type('#text', "xddfg")
.screenshot(':date/homepage.png', function(data){console.log(data);})
.done();
}
};
How i can careate custom function? Now when i write code after done() this code performed at example:

 var fs = require('fs');
module.exports = {
    'Amazon does its thing': function (test) {
        test['open']('http://ya.ru/');
        test.type('#text', "xddfg")
        .screenshot(':date/homepage.png')
        .done(); 

console.log(11111111111);
}
};

Running tests
Running Browser: PhantomJS
11111111111
OS: windows 7 32bit
Browser Version: 1.9.8

RUNNING TEST - "Amazon does its thing"

OPEN http://ya.ru/
TYPE #text
SCREENSHOT 2015-03-25/homepage.png

  • 0 Assertions run
  • TEST - "Amazon does its thing" SUCCEEDED

0/0 assertions passed. Elapsed Time: 3.4 sec
How i can create callback function?

Thanks!

@asciidisco
Copy link
Member

There is no API for that yet, but you can use a little trick:

You can add the log.message method after the screenshot function:

var fs = require('fs');
module.exports = {
    'Amazon does its thing': function (test) {
        test['open']('http://ya.ru/');
        test.type('#text', "xddfg")
        .screenshot(':date/homepage.png') 
        .log.message(function () {
           // Node context, do some nifty fs stuff here
           return 'done'
        })
        .done();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants