Atom 'spec' files not being tested

不想你离开。 提交于 2019-12-12 02:15:25

问题


Following up from my previous question, here, I am trying to get 'spec' files registered by Atom, which I have succeeded in, however now, no matter how many describe and it's I do, it doesn't do anything when I test it.

I use the command, apm test, and all I get is:

[655:0527/083825:WARNING:resource_bundle.cc(305)]  locale_file_path.empty() for locale English
[655:0527/083825:ERROR:file_io.cc(30)] read: expected 40, observed 0
[659:0527/083825:WARNING:resource_bundle.cc(305)] locale_file_path.empty() for locale English
[655:0527/083828:INFO:CONSOLE(52)] "Window load time: 2420ms", source: file:///Applications/Atom.app/Contents/Resources/app.asar/static/index.js (52)


Finished in 0.023 seconds
0 tests, 0 assertions, 0 failures, 0 skipped

Tests passed

Judging by the spec file (which is definitely being registered, as it complains when it doesn't exist), I should have 3 tests run.

My spec file is as follows... (Syntax Highlighter package)

describe "Jazz grammar", ->
  grammar = null

  beforeEach ->
    waitsForPromise ->
      atom.packages.activatePackage("language-jazz")

    runs ->
      grammar = atom.grammars.grammarForScopeName("source.jazz")

    it "parses the grammar", ->
        expect(grammar).toBeDefined()
        expect(grammar.scopeName).toBe "source.jazz"

    it "tokenises keywords", ->
        tokens = grammar.tokenizeLines('func')

        expect(tokens[0][0].value).toBe 'func'
        expect(tokens[0][0].scopes).toEqual ['source.jazz', 'storage.type.jazz']

    it "tokenizes comments inside function parameters", ->
        tokens = grammar.tokenizeLines('module test(arg1, ;; arg2)')

        expect(tokens[0][0].value).toBe 'module'
        expect(tokens[0][0].scopes).toEqual ['source.jazz', 'storage.type.jazz']
        expect(tokens[0][1].scopes).toEqual ['source.jazz', 'comment.line.jazz']

My file structure is as follows:

  • language-jazz
    • grammars
      • jazz.cson
    • snippets
      • language-jazz.cson
    • spec
      • jazz-spec.coffee
    • package.json
    • Other GitHub and Travis CI stuff.

回答1:


The problem is the indentation and structure of your tests in your spec, bear in mind that in CoffeeScript whitespace is significant and the run blocks are used to encapsulate blocks of the code not to group it statements.

So the spec should be:

describe "Jazz grammar", ->
  grammar = null

  beforeEach ->
    waitsForPromise ->
      atom.packages.activatePackage("language-jazz")

  grammar = atom.grammars.grammarForScopeName("source.jazz")

  it "parses the grammar", ->
    expect(grammar).toBeDefined()
    expect(grammar.scopeName).toBe "source.jazz"

  it "tokenises keywords", ->
    tokens = grammar.tokenizeLines('func')

    expect(tokens[0][0].value).toBe 'func'
    expect(tokens[0][0].scopes).toEqual ['source.jazz', 'storage.type.jazz']

  it "tokenizes comments inside function parameters", ->
    tokens = grammar.tokenizeLines('module test(arg1, ;; arg2)')

    expect(tokens[0][0].value).toBe 'module'
    expect(tokens[0][0].scopes).toEqual ['source.jazz', 'storage.type.jazz']
    expect(tokens[0][1].scopes).toEqual ['source.jazz', 'comment.line.jazz']

I've tested this locally and it shows up as three failing tests, as I have implemented your grammar.



来源:https://stackoverflow.com/questions/37472204/atom-spec-files-not-being-tested

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!