Last active
July 17, 2025 02:58
-
-
Save MikaelSoderstrom/4842a97ec399aae1e024 to your computer and use it in GitHub Desktop.
Revisions
-
MikaelSoderstrom renamed this gist
Oct 19, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
MikaelSoderstrom created this gist
Oct 19, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ var path = require('path'); var Nightmare = require('nightmare'); var should = require('chai').should(); describe('Nightmare demo', function () { this.timeout(15000); // Set timeout to 15 seconds, instead of the original 2 seconds var url = 'http://localhost:3000'; describe('Start page', function () { it('should show form when loaded', function (done) { new Nightmare() .goto(url) .evaluate(function () { return document.querySelectorAll('form').length; }, function (result) { result.should.equal(1); done(); }) .run(); }); }); describe('Send form', function () { it('should print the posted string on submit', function (done) { var expected = 'Hello, world!'; new Nightmare() .goto(url) .type('input[name="sometext"]', expected) .click('input[type="submit"]') .wait() .evaluate(function () { return document.querySelector('#result'); }, function (element) { element.innerText.should.equal(expected); done(); }) .run(); }); it('should print "nothing" on submit if no string were provided', function (done) { var expected = 'nothing'; new Nightmare() .goto(url) .click('input[type="submit"]') .wait() .evaluate(function () { return document.querySelector('#result'); }, function (element) { element.innerText.should.equal(expected); done(); }) .run(); }); }); });