4 years ago

[L5.1] Testing with Select2 jQuery plugin

Posted 4 years ago by olimorris

Hi All,

I've just switched over to the brilliant Select2 plugin and I'm currently using it to allow users to search or create new tags in a form. It works perfectly when I manually test it however I'm in the middle of writing a test using Laravel 5.1 and cannot seem to mimic the user input of writing into the Select2 field.

My HTML is:

<select class="tags-field" name="tags[]" data-tags="true" data-placeholder="SKILLS" multiple="multiple"></select>

and my Test code is:

/** @test */
public function it_successfully_posts_a_job()
    $this->click('Post A Job');

    // and I fill out the Post A Job Form
    $this->submitForm('Post Job', [
        'title' => 'Some title',
        'description' => 'Some description',
        'tags' => 'Tag1,Tag2,Tag3',

the error message I get is:

1) PostAJobTest::it_successfully_posts_a_job
InvalidArgumentException: Input "tags" cannot take "Tag1,Tag2,Tag3" as a value (possible values: ).


I wondered whether any of you had come across this problem before?

Please sign in or create an account to participate in this conversation.