`atom.packages.triggerActivationHook()` in specs


Doesn’t seem to work. I tried in the developer console to narrow the issue down. See below, left side the console in the spec runner window, right side the console in a regular atom dev window. My package latex-autocomplete has

"activationHooks": [

in its package.json.

The issue is also present when trying to run my package spec, loading the package and triggering the hook should activate it, but it stays deactivated.


Using an undocumented API call like that in specs is really brittle. You should probably just open a file that is recognized as latex. You should also probably activate the language-latex package before you do that too :grinning:


Yeah, that’s what I was initially doing, but I ran into the same issue : I had to manually run activate() for it to work (and then I did load language-latex anyway, because my package only observes editors with that grammar). It just occurred to me while reading atom packages specs that this way I could decouple the tests of

  • The package is activated by the activationHook
  • Even then, it only observe editors whose grammar is LaTeX

Now I am thinking of getting rid of the first condition (after all, it is checking grammar twice), but even then, I am a bit concerned that the activationHooks don’t seem to work in specs.

By the way, my thanks for your sagacity, there does not seem to be much threads here with which you didn’t interact :slight_smile:


This is a class of problem that I refer to as Testing Code That Isn’t Yours. You’re essentially testing that the activationHooks API works the way you expect when really what you want to be testing is that your package works the way you expect once it is activated by Atom. So I would activate the language-latex package, activate your package, open a file that uses language-latex and go to town :grinning: