Repository: cypress-io/cypress
File: packages/server/test/unit/modes/record_spec.js (JavaScript)

Code before:
    describe('fallback commit information', () => {
      let resetEnv = null

      const env = {
        COMMIT_INFO_BRANCH: 'my-branch-221',
        COMMIT_INFO_MESSAGE: 'best commit ever',
        COMMIT_INFO_EMAIL: 'user@company.com',
        COMMIT_INFO_AUTHOR: 'Agent Smith',
        COMMIT_INFO_SHA: '0123456',
        COMMIT_INFO_REMOTE: 'remote repo',
      }

      beforeEach(() => {
        // stub git commands to return nulls
        sinon.stub(commitInfo, 'getBranch').resolves(null)
        sinon.stub(commitInfo, 'getMessage').resolves(null)
        sinon.stub(commitInfo, 'getEmail').resolves(null)
        sinon.stub(commitInfo, 'getAuthor').resolves(null)
        sinon.stub(commitInfo, 'getSha').resolves(null)
        sinon.stub(commitInfo, 'getRemoteOrigin').resolves(null)
        resetEnv = mockedEnv(env, { clear: true })
      })

      afterEach(() => {
        resetEnv()
      })
    })

    describe('override commit information', () => {
      let resetEnv = null

      const env = {
        COMMIT_INFO_BRANCH: 'my-branch-221',
        COMMIT_INFO_MESSAGE: 'best commit ever',
        COMMIT_INFO_EMAIL: 'user@company.com',
        COMMIT_INFO_AUTHOR: 'Agent Smith',
        COMMIT_INFO_SHA: '0123456',
        COMMIT_INFO_REMOTE: 'remote repo',
      }

      beforeEach(() => {
        // stub git commands to return values
        sinon.stub(commitInfo, 'getBranch').resolves('my-ci-branch')
        sinon.stub(commitInfo, 'getMessage').resolves('my ci msg')
        sinon.stub(commitInfo, 'getEmail').resolves('my.ci@email.com')
        sinon.stub(commitInfo, 'getAuthor').resolves('My CI Name')
        sinon.stub(commitInfo, 'getSha').resolves('mycisha')
        sinon.stub(commitInfo, 'getRemoteOrigin').resolves('my ci remote')
        resetEnv = mockedEnv(env, { clear: true })
      })


Review comment (bug):
```suggestion
      })
      
      it('calls api.createRun with the commit extracted from environment variables', () => {
        const createRun = sinon.stub(api, 'createRun').resolves()
        const runAllSpecs = sinon.stub()

        return recordMode.createRunAndRecordSpecs({
          key: 'foo',
          sys: {},
          browser: {},
          runAllSpecs,
        })
        .then(() => {
          expect(runAllSpecs).to.have.been.calledWith({ parallel: false })
          expect(createRun).to.have.been.calledOnce
          expect(createRun.firstCall.args).to.have.length(1)
          const { commit } = createRun.firstCall.args[0]

          debug('git is %o', commit)

          expect(commit).to.deep.equal({
            sha: env.COMMIT_INFO_SHA,
            branch: env.COMMIT_INFO_BRANCH,
            authorName: env.COMMIT_INFO_AUTHOR,
            authorEmail: env.COMMIT_INFO_EMAIL,
            message: env.COMMIT_INFO_MESSAGE,
            remoteOrigin: env.COMMIT_INFO_REMOTE,
            defaultBranch: null,
          })
        })
      })
```

Code after:
    describe('fallback commit information', () => {
      let resetEnv = null

      const env = {
        COMMIT_INFO_BRANCH: 'my-branch-221',
        COMMIT_INFO_MESSAGE: 'best commit ever',
        COMMIT_INFO_EMAIL: 'user@company.com',
        COMMIT_INFO_AUTHOR: 'Agent Smith',
        COMMIT_INFO_SHA: '0123456',
        COMMIT_INFO_REMOTE: 'remote repo',
      }

      beforeEach(() => {
        // stub git commands to return nulls
        sinon.stub(commitInfo, 'getBranch').resolves(null)
        sinon.stub(commitInfo, 'getMessage').resolves(null)
        sinon.stub(commitInfo, 'getEmail').resolves(null)
        sinon.stub(commitInfo, 'getAuthor').resolves(null)
        sinon.stub(commitInfo, 'getSha').resolves(null)
        sinon.stub(commitInfo, 'getRemoteOrigin').resolves(null)
        resetEnv = mockedEnv(env, { clear: true })
      })

      afterEach(() => {
        resetEnv()
      })

      it('calls api.createRun with the commit extracted from environment variables', () => {
        const createRun = sinon.stub(api, 'createRun').resolves()
        const runAllSpecs = sinon.stub()

        return recordMode.createRunAndRecordSpecs({
          key: 'foo',
          sys: {},
          browser: {},
          runAllSpecs,
        })
        .then(() => {
          expect(runAllSpecs).to.have.been.calledWith({ parallel: false })
          expect(createRun).to.have.been.calledOnce
          expect(createRun.firstCall.args).to.have.length(1)
          const { commit } = createRun.firstCall.args[0]

          debug('git is %o', commit)

          expect(commit).to.deep.equal({
            sha: env.COMMIT_INFO_SHA,
            branch: env.COMMIT_INFO_BRANCH,
            authorName: env.COMMIT_INFO_AUTHOR,
            authorEmail: env.COMMIT_INFO_EMAIL,
            message: env.COMMIT_INFO_MESSAGE,