                 email      :  'Plese sign up and join this project.'
                 title      :  'Team Project'
                 link2proj  :  "#{base_url}/projects/#{project_id}"
-            cb    :  ->
-                #expect(resp?.event).toBe('invite_noncloud_collaborators_resp')
-                #expect(api.last_email?.subject).toBe('CoCalc Invitation')
-                done()
+            cb    :  (err, resp) ->
+                check = (err, resp) ->
+                    opts0 = email.send_email.args[0][0]
+                    expect(resp?.event).toBe('invite_noncloud_collaborators_resp')
+                    expect(opts0?.subject).toBe('CoCalc Invitation')
+                    done()
+                # sending email is probably async, wait a bit
+                setTimeout((-> check(err, resp)), 100)
 
 
     it "removes collaborator", (done) ->

                        title       : 'COLLABTEST2'
                        description : 'Testing collaboration ops'
                    cb    : (err, resp) ->
                        project_id2 = resp.project_id
                        winston.info("project_id2: #{project_id2}")
                        done(err)
            (cb) ->
                api.call
                    event : 'invite_collaborator'
                    body  :
                        account_id     : account_id2
                        project_id     : project_id2
                        title          : 'PROJECT_TITLE'
                        link2proj      : 'https://link.to.project/'
                        replyto        : 'cocalc+2@sagemath.com'
                        replyto_name   : 'Sage2 CoCalc2'
                        email          : 'BODY_OF_EMAIL_1'
                        subject        : 'SUBJECT_OF_EMAIL_1'
                    cb    : (err, resp) ->

                        setTimeout((-> cb(err)), 100)

        ], (err) ->
            expect(err).toBe('')
            expect(err?).toBe(false)
            opts0 = email.send_email.args[0][0]
            expect(opts0.subject).toBe('SUBJECT_OF_EMAIL_1')
            expect(opts0.from).toBe('cocalc+3@sagemath.com')
            expect(opts0.fromname).toBe('Sage3 CoCalc3')
            expect(opts0.body.indexOf('BODY_OF_EMAIL_1') > 0).toBe(true)
            # no second email
            winston.info("email.send_email.args: #{misc.to_json(email.send_email.args)}")
