I’ve got a fairly simple Meteor app:
<template name="homePage">
<form>
<input id="dummy" value="Wow">
<input id="data">
<button type="submit">Do It</button>
</form>
</template>
Template.homePage.events({
'submit form': function (event, template) {
var v1 = template.$('#data').val();
event.preventDefault();
console.log('Click event triggered ', v1);
Things.insert({thing: v1});
}
});
And I have the following PhantomJS script:
var page = require('webpage').create();
page.onConsoleMessage = function (msg) {
console.log(msg);
};
page.open('http://localhost:3000/', function () {
page.evaluate(function () {
console.log($('#dummy').val());
$('#data').val('Yo yo yo');
$('form button').click();
});
phantom.exit();
});
I can see in the log that the click event is being triggered, but the Things.insert()
call is not working apparently, because the database is empty when I check it. Is there some special way to have PhantomJS test Meteor apps? (the plan is to script Phantom to simulate 10 users filling out the form differently and submitting, about 2 seconds apart from each other)
If I open this in Firefox and open a console and type the below, it works as expected.
$('#data').val('test 123'); $('form button').click();