LoginSignup
5

More than 5 years have passed since last update.

grunt-contrib-jasmine の phamtomjs 用テンプレートに jade を使う

Last updated at Posted at 2013-10-24
Gruntfile.coffee
jade = require "jade"
module.exports = (grunt) =>
    grunt.initConfig
        jasmine:
            files: [
                "public/js/lib/zepto.min.js"
                "public/js/main.js"
                ...(依存ライブラリとテスト対象)
            ]
            options:
                specs: [
                    "test/js/mainSpec.js"
                    ....(実行したいテスト)
                ]
                template:
                    process: (grunt, task, contest) ->
                        tt = "test/template.jade"
                        src = grunt.file.read tt
                        compiled = jade.compile(src, {pretty:true, filename:tt})(context)
                outfile: "test/js/_SpecRunner.html"
                keepRunner: true
test/template.jade
!!!
html
    head
        meta(charset="utf8")
        // 順番が重要
        jss = [scripts.jasmine, scripts.vendor, scripts.helpers, scripts.src, scripts.specs, scripts.reporters, scripts.start]
        for js in jss
            for path in js
                script(type="text/javascript", src=path)
    body
        ...(テストに必要なHTMLをinclude, mixinで書く)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5