[Solved] Spec fails, but works right in editor


#1

We’re running into an odd case where a package spec appears to be working differently when run live than when in “test mode”. The PR with the code in question is here:

The most likely source of the problem is checking for styles here (I can’t post another link).

Sorry for the messed up links. I’m trying to around restrictions on new users.

Anyone run into something like that?

Any guidance on how to debug specs? It’s hard when you can’t see what the “test” editor is doing.


#2

Is soft wrap turned on for Markdown files on your machine? Soft wrap can affect screen rows (not buffer rows) and if the test “window” is too narrow (I forget how wide it is set to be for tests), it might throw off your calculations compared to when you run it in the full editor.


#3

Soft wrap is not turned on. Our spec has several tests using screen rows that work fine. The last failing test involves checking for styles. That’s the only difference that we can think affects how the spec works.


#4

Have you included the jasmine.attachToDOM call for the element containing the stuff you’re checking for styles? Perhaps a real DOM would help?


[Solved] editor:newline behaves differently in package spec
#5

That didn’t work either, but it was a great suggestion. It might lead to different discussions to track down.


#6

The following,

  editor = atom.workspace.getActiveTextEditor()
  scopes = editor.scopeDescriptorForBufferPosition([row,0]).scopes

Always returns ["text.plain.null-grammar"] when run from a spec. When run from the editor, it returns something like ["source.gfm", "comment.block.gfm"], depending on where the cursor was.


#7

I think this is because you never activate the language-markdown package in your specs, so the default grammar is always used for open files.


#8

BTW, you should activate it before opening any file so that the workspace can detect the grammar.


#9

That did it! Thanks so much @abe!