简体   繁体   English

如何加速资产编译测试?

[英]How to speed up assets compilation for tests?

Running Guard with Spin works great to keep my testing fast, except when assets are relevant and need compiling. 使用Spin运行Guard可以很好地保持我的测试速度,除非资产是相关的并且需要编译。 It seems that the test environments recompiles all assets whenever I change something in them. 似乎每当我更改其中的某些内容时,测试环境都会重新编译所有资产。 I've seen examples of deployment scripts that only recompile assets whose source has changed. 我已经看到了部署脚本的示例,这些脚本只重新编译源已更改的资产。 Can this be done for testing too? 这可以用于测试吗? Or is there another way to speed up asset compilation for tests? 或者是否有另一种加速测试资产编译的方法?

I'm using a rather specific setup so I'll be happy to supply more information if needed, though I feel the answer from this question might be of use in many more cases than just mine. 我正在使用一个相当具体的设置,所以我很乐意在需要时提供更多信息,但我觉得这个问题的答案可能会在更多的情况下使用,而不仅仅是我的。

You can take a look at this article written two months ago . 你可以看一下两个月前写的这篇文章 It seems rather complex task . 这似乎相当复杂。 Nathan has written a gem that precompiles only changes , made to assets . Nathan写了一个宝石,预编译资产。 It can be used in development and testing env. 它可以用于开发和测试环境。

EDIT : Here is another article , related with speeding up our tests . 编辑:这是另一篇与加快测试有关的文章 It has a different point of view about js testing . 它对js测试有不同的观点。

You can for example avoid adding require_tree in Your application js and css files. 例如,您可以避免在应用程序js和css文件中添加require_tree

In addition, use proper file extensions - if something is js - then name it like normal js files. 此外,使用适当的文件扩展名 - 如果某些东西是js - 然后将其命名为普通的js文件。 Same for css and scss. 对于css和scss也是如此。

You can also precompile assets locally to have it compiled locally on development by command rake assets:precompile - but remember to delete it after tests to see changes in assets next time (it can be generated in vendor folder) 您还可以在本地对资产进行预编译,以便在开发时通过命令rake assets:precompile - 但请记住在测试之后将其删除以查看下次资产的更改(可以在供应商文件夹中生成)

I am sure but you can try: 我相信你可以尝试:

In application.js file write all js file in tree order like this: 在application.js文件中按树顺序写下所有js文件,如下所示:

//= require jquery // =需要jquery

//= require jquery_ui // =需要jquery_ui

//= require jquery.ui.core // =需要jquery.ui.core

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM