Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionView::Template::Error: 785: unexpected token at ''

This error happens randomly during testing (standard Rails testing toolkit) after running rails test. Failed test can be any test in any file.

This error happens usually in testing environment during CI/CD process. Locally it occurs very rarely.

Here is a full stack trace:

Error:
SitePositionsControllerTest#test_should_create_position_link:
ActionView::Template::Error: 785: unexpected token at ''
    app/views/layouts/site/application.html.erb:10
    test/controllers/site_positions_controller_test.rb:28:in `block (2 levels) in <class:SitePositionsControllerTest>'
    test/controllers/site_positions_controller_test.rb:27:in `block in <class:SitePositionsControllerTest>'
    test/test_helper.rb:64:in `block (3 levels) in run'
    test/test_helper.rb:63:in `block (2 levels) in run'
    test/test_helper.rb:62:in `block in run'
    test/test_helper.rb:54:in `run'

rails test test/controllers/site_positions_controller_test.rb:18
like image 287
Dmitry Matveyev Avatar asked Oct 30 '19 08:10

Dmitry Matveyev


1 Answers

Like @jellymann I was having this issue on calls to javascript_pack_tag.

I added bin/rails webpacker:compile before rails test and it seems to have resolved the issue.

This was happening pretty regularly. In the two days since I made that change, at least a dozen or so builds have gone off without this error.

like image 195
Todd Avatar answered Nov 09 '22 23:11

Todd