title: Firebase cloud function Firestore trigger onWrite not behaving as expected when testing locally
body: <p>I am testing Firestore triggered Firebase Cloud Function locally in Node using Firebase Functions Shell.</p>
  
  <p>When working with a onWrite trigger and passing a new document by calling <code>updateMonth({foo:'new'})</code> from the functions shell, I can't get a reference to the new document.</p>
  
  <pre><code>exports.updateMonth = functions.firestore
  .document('users/{userId}').onWrite((change, context) =&gt; {
      const document = change.after.exists ? change.after.data() : null;
      console.log("change.after.exists", change.after.exists)
      console.log("change.before.exists", change.before.exists)
      const oldDocument = change.before.data();
      console.log("Old:",oldDocument)
      return true
  })
  </code></pre>
  
  <p>When calling with both a before and after to emulate a document update <code>updateMonth({before:{foo:'old'},after:{foo:'new'}})</code> it works as expected.
  However, when called with just <code>updateMonth({foo:'new'})</code>, both before and after documents don't seem to exist :</p>
  
  <pre><code>i  functions: Preparing to emulate functions.
  Warning: You're using Node.js v8.4.0 but Google Cloud Functions only supports v6.11.5.
  +  functions: hi
  +  functions: helloWorld
  +  functions: updateMonth
  firebase &gt; updateMonth({before:{foo:'old'},after:{foo:'new'}})
  'Successfully invoked function.'
  firebase &gt; info: User function triggered, starting execution
  info: change.after.exists true
  info: change.before.exists true
  info: Old: { foo: 'old' }
  info: Execution took 20 ms, user function completed successfully
  
  firebase &gt; updateMonth({foo:'new'})
  'Successfully invoked function.'
  firebase &gt; info: User function triggered, starting execution
  info: change.after.exists false
  change.before.exists false
  Old: undefined
  Execution took 2 ms, user function completed successfully
  </code></pre>
  
  <p>I'm not sure how I can get a reference to the new document being created. I would expect the change.after.exists to be true in that case.</p>