await testCollection.insertMany(testArray, { ordered: false });

I have this code. I found that putting { ordered: false } will prevent getting E11000 error code. But, it looks like, it does not. Is there any way that I can avoid this error? I want to skip and do not insert a doc that has the same _id code.

MongoDB insertMany skip the same _id field to avoid 'code: 11000,'
You can't avoid error, but you can proceed with inserting. See here. For example:
    MongoDB Enterprise replset:PRIMARY> db.products.insert(
    ...    [
    ...      { _id: 20, item: "lamp", qty: 50, type: "desk" },
    ...      { _id: 21, item: "lamp", qty: 20, type: "floor" },
    ...      { _id: 21, item: "lamp", qty: 20, type: "floor" },
    ...      { _id: 22, item: "bulk", qty: 100 }
    ...    ],
    ...    { ordered: false }
    ... )
    BulkWriteResult({
            "writeErrors" : [
                    {
                            "index" : 2,
                            "code" : 11000,
                            "errmsg" : "E11000 duplicate key error collection: newdb1.products index: _id_ dup key: { _id: 21.0 }",
                            "op" : {
                                    "_id" : 21,
                                    "item" : "lamp",
                                    "qty" : 20,
                                    "type" : "floor"
                            }
                    }
            ],
            "writeConcernErrors" : [ ],
            "nInserted" : 3,
            "nUpserted" : 0,
            "nMatched" : 0,
            "nModified" : 0,
            "nRemoved" : 0,
            "upserted" : [ ]
    })
    MongoDB Enterprise replset:PRIMARY> db.products.find()
    { "_id" : 20, "item" : "lamp", "qty" : 50, "type" : "desk" }
    { "_id" : 21, "item" : "lamp", "qty" : 20, "type" : "floor" }
    { "_id" : 22, "item" : "bulk", "qty" : 100 }

you may see, that if you remove { ordered: false }, the only inserted records will be records before first error accured:
MongoDB Enterprise replset:PRIMARY> db.products.find()
{ "_id" : 20, "item" : "lamp", "qty" : 50, "type" : "desk" }
{ "_id" : 21, "item" : "lamp", "qty" : 20, "type" : "floor" }

