Creating a snippet with the text "undefined"


#1

I’m using snippets to create templates for my source and test file boilerplate.
I have a multi-line snippet that includes the text “undefined”

'.source.js':
  'Snippet Name':
    'prefix': 'reducer.spec'
    'body': """
import test from 'ava'
import deepFreeze from 'deep-freeze'

import actions from '$1/actions'
import reducer from '$2/reducer'

const DEFAULT_STATE = {}

const immutableReducer = (state, action) => {
  if (state) deepFreeze(state)
  deepFreeze(action)
  return reducer(state, action)
}

test('#initialises to default state', t => {
  const action = { type: 'UNDEFINED' }
  const newState = immutableReducer(undefined, action)
  t.deepEqual(newState, DEFAULT_STATE)
})

test('#unknown actions return previous state', t => {
  const action = { type: 'UNDEFINED' }
  const state = { foo: 'bar' }
  const newState = immutableReducer(state, action)
  t.deepEqual(newState, state)
})

$3
    """

When the snippet tempate is inserted in my file it leaves out the “undefined” text. Is there a way around this?


#2

The snippet works for me, could this be caused by a third-party package you installed?


#3

I was able to reproduce your problem using Atom v1.14.3 on Mac OS X 10.12.3 but only with your specific snippet. When I tried to create smaller snippets that reproduced the problem, I couldn’t. Would you mind opening an issue on https://github.com/atom/snippets so that we can dig into this further?