title: Transaction numbers are only allowed on storage engines that support document-level locking - MongodbMemoryServer/Mochai/Chai/Supertest
body: <h2>FIXED: USER storageEngine: "wiredTiger"</h2>
  
  <p>I use Mocha / Chai / Supertest and Mongodb-Memory-Server to test my app. But's I received error: <code>Transaction numbers are only allowed on storage engines that support document-level locking</code></p>
  
  <p>In real database and test by postman, it's working well.</p>
  
  <p>My code:</p>
  
  <p>In database.js</p>
  
  <pre><code>const mongoose = require('mongoose')
  const { MongoMemoryReplSet } = require('mongodb-memory-server')
  
  mongoose.set('useFindAndModify', false);
  const connect = async () =&gt; {
      try {
          let url = process.env.MONGO_URL
  
          let options = {
              //Something
          }
          if (process.env.NODE_ENV === 'test') {
              const replSet = new MongoMemoryReplSet();
              await replSet.waitUntilRunning();
              const uri = await replSet.getUri();
  
              await mongoose.connect(uri, options)
  
              //log connected
          } else {
              await mongoose.connect(url, options)
              //log connected
          }
      } catch (error) {
          //error
      }
  }
  </code></pre>
  
  <p>I have two model: Company and User. I made a function to add a member to company with used <code>transaction</code>. My code</p>
  
  <pre><code>const addMember = async (req, res, next) =&gt; {
      const { companyId } = req.params
      const { userId } = req.body
  
      const session = await mongoose.startSession()
      try {
          await session.withTransaction(async () =&gt; {
              const [company, user] = await Promise.all([
                  Company.findOneAndUpdate(
                      //Something
                  ).session(session),
  
                  User.findByIdAndUpdate(
                      //Something
                  ).session(session)
              ])
  
              //Something if... else
  
              return res.json({
                  message: `Add member successfully!`,
              })
          })
      } catch (error) {
          //error
      }
  }
  </code></pre>
  
  <p>Here's router:</p>
  
  <pre><code>router.post('/:companyId/add-member',
      authentication.required,
      company.addMember
  )
  </code></pre>
  
  <p>Test file: </p>
  
  <pre><code>const expect = require('chai').expect
  const request = require('supertest')
  const app = require('../app')
  
  describe('POST /company/:companyId/add-member', () =&gt; {
      it('OK, add member', done =&gt; {
          request(app).post(`/company/${companyIdEdited}/add-member`)
          .set({ "x-access-token": signedUserTokenKey })
          .send({userId: memberId})
          .then(res =&gt; {
              console.log(res.body)
              expect(res.statusCode).to.equals(200)
              done()
          })
          .catch((error) =&gt; done(error))
      })
  })
  </code></pre>
  
  <p>And i received error: Transaction numbers are only allowed on storage engines that support document-level locking'</p>
  
  <p>How can I fix this?</p>