From 3f79b18a264241861bf34fe2f42d4b09444f8e8e Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sun, 4 Sep 2022 16:25:15 -0400 Subject: [PATCH 01/28] feat: run tests on Deno Re: #9056 --- .github/workflows/test.yml | 17 +++++++++++++++ lib/schematype.js | 2 +- package.json | 1 + test/deno.js | 33 +++++++++++++++++++++++++++++ test/docs/lean.test.js | 7 +++++- test/query.test.js | 7 ++++++ test/schema.subdocumentpath.test.js | 3 +-- test/schema.test.js | 5 +++++ test/schematype.test.js | 2 ++ 9 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 test/deno.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8edfff05c8c..89da7ec2a4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,6 +91,23 @@ jobs: with: name: coverage path: coverage + + test-deno: + runs-on: ubuntu-latest + name: Deno tests + steps: + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 + - name: Setup node + uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3.4.1 + with: + node-version: 16 + - name: Setup Deno + uses: actions/setup-deno #v1 + with: + deno-version: v1.25.x + - run: npm install + - name: Run Deno tests + run: npm run test-deno test-replica-sets: needs: diff --git a/lib/schematype.js b/lib/schematype.js index 0cc6c3eea59..837719a32a9 100644 --- a/lib/schematype.js +++ b/lib/schematype.js @@ -56,7 +56,7 @@ function SchemaType(path, options, instance) { const defaultOptionsKeys = Object.keys(defaultOptions); for (const option of defaultOptionsKeys) { - if (defaultOptions.hasOwnProperty(option) && !options.hasOwnProperty(option)) { + if (defaultOptions.hasOwnProperty(option) && !Object.prototype.hasOwnProperty.call(options, option)) { options[option] = defaultOptions[option]; } } diff --git a/package.json b/package.json index 2767c008775..3360a3ccc8c 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "release-legacy": "git pull origin 5.x && git push origin 5.x --tags && npm publish --tag legacy", "mongo": "node ./tools/repl.js", "test": "mocha --exit ./test/*.test.js", + "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --unstable ./test/deno.js", "test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit ./test/*.test.js", "test-tsd": "node ./test/types/check-types-filename && tsd", "tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}", diff --git a/test/deno.js b/test/deno.js new file mode 100644 index 00000000000..a13618ae410 --- /dev/null +++ b/test/deno.js @@ -0,0 +1,33 @@ +'use strict'; + +import { createRequire } from "https://deno.land/std/node/module.ts"; + +import { parse } from "https://deno.land/std/flags/mod.ts" +const args = parse(Deno.args); + +const require = createRequire(import.meta.url); + +const Mocha = require('mocha'); +const fs = require('fs'); +const path = require('path'); + +const mocha = new Mocha({ + ...(args.g ? { fgrep: '' + args.g } : {}) +}); + +const testDir = 'test'; +const files = fs.readdirSync(testDir); + +const ignoreFiles = new Set(['browser.test.js', 'connection.test.js', 'index.test.js']); + +for (const file of files) { + if (!file.endsWith('.test.js') || ignoreFiles.has(file)) { + continue; + } + + mocha.addFile(path.join(testDir, file)); +} + +mocha.run(function(failures) { + process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures +}); \ No newline at end of file diff --git a/test/docs/lean.test.js b/test/docs/lean.test.js index 49cd0c45aad..576d8bcdcf3 100644 --- a/test/docs/lean.test.js +++ b/test/docs/lean.test.js @@ -1,7 +1,6 @@ 'use strict'; const assert = require('assert'); -const v8Serialize = require('v8').serialize; const start = require('../common'); // This file is in `es-next` because it uses async/await for convenience @@ -23,6 +22,12 @@ describe('Lean Tutorial', function() { }); it('compare sizes lean vs not lean', async function() { + // acquit:ignore:start + if (typeof Deno !== 'undefined') { + return this.skip(); // Deno does not support v8.serialize() + } + const v8Serialize = require('v8').serialize; + // acquit:ignore:end const schema = new mongoose.Schema({ name: String }); const MyModel = mongoose.model('Test', schema); diff --git a/test/query.test.js b/test/query.test.js index d357d256001..fc1ad0b4080 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -2339,6 +2339,13 @@ describe('Query', function() { }); it('throw on sync exceptions in callbacks (gh-6178)', function(done) { + // Deno doesn't support 'uncaughtException', so there's no way to test this in Deno + // without starting a separate process. + // See: https://stackoverflow.com/questions/64871554/deno-how-to-handle-exceptions + if (typeof Deno !== 'undefined') { + return this.skip(); + } + const schema = new Schema({}); const Test = db.model('Test', schema); diff --git a/test/schema.subdocumentpath.test.js b/test/schema.subdocumentpath.test.js index d7a131ab5c3..60d4a1e2f3c 100644 --- a/test/schema.subdocumentpath.test.js +++ b/test/schema.subdocumentpath.test.js @@ -179,7 +179,7 @@ describe('SubdocumentPath', function() { assert.ok(err); assert.ok(err.errors['nested']); - mongoose.Schema.Types.Subdocument.set('required', false); + delete mongoose.Schema.Types.Subdocument.defaultOptions.required; }); it('supports setting _id globally (gh-11541) (gh-8883)', function() { @@ -197,6 +197,5 @@ describe('SubdocumentPath', function() { assert.ok(!doc.nested._id); delete mongoose.Schema.Types.Subdocument.defaultOptions._id; - mongoose.Schema.Types.Subdocument.set('required', false); }); }); diff --git a/test/schema.test.js b/test/schema.test.js index c09895de3b3..0a994b87398 100644 --- a/test/schema.test.js +++ b/test/schema.test.js @@ -1178,6 +1178,11 @@ describe('schema', function() { describe('other contexts', function() { it('work', function(done) { + if (typeof Deno !== 'undefined') { + // Deno throws "Not implemented: Script.prototype.runInNewContext" + return this.skip(); + } + const str = 'code = {' + ' name: String' + ', arr1: Array ' + diff --git a/test/schematype.test.js b/test/schematype.test.js index 6b96bde4377..6e07390a2bc 100644 --- a/test/schematype.test.js +++ b/test/schematype.test.js @@ -224,6 +224,8 @@ describe('schematype', function() { // Assert assert.equal(schema.path('test').options.someRandomOption, true); + + delete type.defaultOptions.someRandomOption; }); }); }); From c1a4823d7f6a06d58ab1c68b3ac274fc0a94be2e Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sun, 4 Sep 2022 16:30:37 -0400 Subject: [PATCH 02/28] chore: correct action name --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 89da7ec2a4a..bb4fed97caf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -102,7 +102,7 @@ jobs: with: node-version: 16 - name: Setup Deno - uses: actions/setup-deno #v1 + uses: denoland/setup-deno@v1 with: deno-version: v1.25.x - run: npm install From 52110b64600e175d96779c78d9d7dfc2d003bf02 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sun, 4 Sep 2022 16:33:24 -0400 Subject: [PATCH 03/28] chore: setup MongoDB server on deno tests Re: #9056 --- .github/workflows/test.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb4fed97caf..d3023817a68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,10 +93,20 @@ jobs: path: coverage test-deno: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 name: Deno tests steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 + - name: Setup + run: | + wget -q https://downloads.mongodb.org/linux/mongodb-linux-x86_64-ubuntu-2004-6.0.0.tgz + tar xf mongodb-linux-x86_64-ubuntu-2004-6.0.0.tgz + mkdir -p ./data/db/27017 ./data/db/27000 + printf "\ntimeout: 8000" >> ./.mocharc.yml + ./mongodb-linux-x86_64-ubuntu-2004-6.0.0/bin/mongod --setParameter ttlMonitorSleepSecs=1 --fork --dbpath ./data/db/27017 --syslog --port 27017 + sleep 2 + mongod --version + echo `pwd`/mongodb-linux-x86_64-ubuntu-2004-6.0.0/bin >> $GITHUB_PATH - name: Setup node uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3.4.1 with: From 8697ce575f861aeb1301dc55e7f34837eeed4dab Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sun, 4 Sep 2022 16:35:34 -0400 Subject: [PATCH 04/28] chore: correct download path re: #9056 --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3023817a68..6c2dc7af353 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -99,14 +99,14 @@ jobs: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 - name: Setup run: | - wget -q https://downloads.mongodb.org/linux/mongodb-linux-x86_64-ubuntu-2004-6.0.0.tgz - tar xf mongodb-linux-x86_64-ubuntu-2004-6.0.0.tgz + wget -q https://downloads.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-6.0.0.tgz + tar xf mongodb-linux-x86_64-ubuntu2004-6.0.0.tgz mkdir -p ./data/db/27017 ./data/db/27000 printf "\ntimeout: 8000" >> ./.mocharc.yml - ./mongodb-linux-x86_64-ubuntu-2004-6.0.0/bin/mongod --setParameter ttlMonitorSleepSecs=1 --fork --dbpath ./data/db/27017 --syslog --port 27017 + ./mongodb-linux-x86_64-ubuntu2004-6.0.0/bin/mongod --setParameter ttlMonitorSleepSecs=1 --fork --dbpath ./data/db/27017 --syslog --port 27017 sleep 2 mongod --version - echo `pwd`/mongodb-linux-x86_64-ubuntu-2004-6.0.0/bin >> $GITHUB_PATH + echo `pwd`/mongodb-linux-x86_64-ubuntu2004-6.0.0/bin >> $GITHUB_PATH - name: Setup node uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3.4.1 with: From 32e805566be06427c844848be86001c5fc84afbd Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 11:39:51 -0400 Subject: [PATCH 05/28] test: convert #3973 test to async/await to try to work around deno test failures re: #9056 --- test/model.populate.test.js | 53 ++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/test/model.populate.test.js b/test/model.populate.test.js index 58c808c2fb1..0c438e0d09c 100644 --- a/test/model.populate.test.js +++ b/test/model.populate.test.js @@ -3783,7 +3783,7 @@ describe('model: populate:', function() { } }); - it('4 level population (gh-3973)', function(done) { + it('4 level population (gh-3973)', async function() { const level4Schema = new Schema({ name: { type: String } }); @@ -3809,36 +3809,29 @@ describe('model: populate:', function() { const level1 = db.model('Test', level1Schema); const l4docs = [{ name: 'level 4' }]; + const l4 = await level4.create(l4docs); - level4.create(l4docs, function(error, l4) { - assert.ifError(error); - const l3docs = [{ name: 'level 3', level4: l4[0]._id }]; - level3.create(l3docs, function(error, l3) { - assert.ifError(error); - const l2docs = [{ name: 'level 2', level3: l3[0]._id }]; - level2.create(l2docs, function(error, l2) { - assert.ifError(error); - const l1docs = [{ name: 'level 1', level2: l2[0]._id }]; - level1.create(l1docs, function(error, l1) { - assert.ifError(error); - const opts = { - path: 'level2', - populate: { - path: 'level3', - populate: { - path: 'level4' - } - } - }; - level1.findById(l1[0]._id).populate(opts).exec(function(error, obj) { - assert.ifError(error); - assert.equal(obj.level2[0].level3[0].level4[0].name, 'level 4'); - done(); - }); - }); - }); - }); - }); + const l3docs = [{ name: 'level 3', level4: l4[0]._id }]; + const l3 = await level3.create(l3docs); + + const l2docs = [{ name: 'level 2', level3: l3[0]._id }]; + const l2 = await level2.create(l2docs); + + const l1docs = [{ name: 'level 1', level2: l2[0]._id }]; + const l1 = await level1.create(l1docs); + + const opts = { + path: 'level2', + populate: { + path: 'level3', + populate: { + path: 'level4' + } + } + }; + + const obj = await level1.findById(l1[0]._id).populate(opts).exec(); + assert.equal(obj.level2[0].level3[0].level4[0].name, 'level 4'); }); it('deep populate two paths (gh-3974)', function(done) { From f4d8f611081db9e1cc9fbbdaf5ec6667bc9d209d Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 11:49:41 -0400 Subject: [PATCH 06/28] test: ignore deno.js for linter, convert a few more populate tests to async/await for better debug --- scripts/create-tarball.js | 2 +- test/.eslintrc.yml | 2 + test/model.populate.test.js | 130 +++++++++++++++--------------------- 3 files changed, 57 insertions(+), 77 deletions(-) diff --git a/scripts/create-tarball.js b/scripts/create-tarball.js index e38a3c63b4a..f93d229691a 100644 --- a/scripts/create-tarball.js +++ b/scripts/create-tarball.js @@ -4,4 +4,4 @@ const { execSync } = require('child_process'); const { name, version } = require('../package.json'); execSync('npm pack'); -execSync(`mv ${name}-${version}.tgz ${name}.tgz`); \ No newline at end of file +execSync(`mv ${name}-${version}.tgz ${name}.tgz`); diff --git a/test/.eslintrc.yml b/test/.eslintrc.yml index 038d1bbc52f..5caa2b37c25 100644 --- a/test/.eslintrc.yml +++ b/test/.eslintrc.yml @@ -3,3 +3,5 @@ env: rules: # In `document.test.js` we sometimes use self assignment to test setters no-self-assign: off +ignorePatterns: + - deno.js \ No newline at end of file diff --git a/test/model.populate.test.js b/test/model.populate.test.js index 0c438e0d09c..03bd6b26af3 100644 --- a/test/model.populate.test.js +++ b/test/model.populate.test.js @@ -3713,7 +3713,7 @@ describe('model: populate:', function() { assert.deepEqual(arr, ['Shaq', 'Kobe', 'Horry']); }); - it('deep populate array -> array (gh-3954)', function(done) { + it('deep populate array -> array (gh-3954)', async function() { const personSchema = new Schema({ name: { type: String } }); @@ -3731,56 +3731,42 @@ describe('model: populate:', function() { const Team = db.model('Team', teamSchema); const Game = db.model('Test', gameSchema); - const people = [ + const people = await Person.create([ { name: 'Shaq' }, { name: 'Kobe' }, { name: 'Horry' }, { name: 'Duncan' }, { name: 'Robinson' }, { name: 'Johnson' } - ]; + ]); - Person.create(people, function(error, people) { - assert.ifError(error); - const lakers = { - name: 'Lakers', - members: [people[0]._id, people[1]._id, people[2]._id] - }; - const spurs = { - name: 'Spurs', - members: [people[3]._id, people[4]._id, people[5]._id] - }; - const teams = [lakers, spurs]; - Team.create(teams, function(error, teams) { - assert.ifError(error); - const game = { - teams: [teams[0]._id, teams[1]._id] - }; - Game.create(game, function(error, game) { - assert.ifError(error); - test(game._id); - }); - }); - }); + const lakers = { + name: 'Lakers', + members: [people[0]._id, people[1]._id, people[2]._id] + }; + const spurs = { + name: 'Spurs', + members: [people[3]._id, people[4]._id, people[5]._id] + }; + const teams = await Team.create([lakers, spurs]); - function test(id) { - const query = Game.findById(id).populate({ - path: 'teams', - select: 'name members', - populate: { path: 'members', select: 'name' } - }); - query.exec(function(error, doc) { - assert.ifError(error); - const players = doc.toObject().teams[0].members. - concat(doc.toObject().teams[1].members); - const arr = players.map(function(v) { - return v.name; - }); - assert.deepEqual(arr, - ['Shaq', 'Kobe', 'Horry', 'Duncan', 'Robinson', 'Johnson']); - done(); - }); - } + const game = { + teams: [teams[0]._id, teams[1]._id] + }; + const { _id } = await Game.create(game); + + const doc = await Game.findById(_id).populate({ + path: 'teams', + select: 'name members', + populate: { path: 'members', select: 'name' } + }); + const players = doc.toObject().teams[0].members. + concat(doc.toObject().teams[1].members); + const arr = players.map(function(v) { + return v.name; + }); + assert.deepEqual(arr, + ['Shaq', 'Kobe', 'Horry', 'Duncan', 'Robinson', 'Johnson']); }); it('4 level population (gh-3973)', async function() { @@ -3834,7 +3820,7 @@ describe('model: populate:', function() { assert.equal(obj.level2[0].level3[0].level4[0].name, 'level 4'); }); - it('deep populate two paths (gh-3974)', function(done) { + it('deep populate two paths (gh-3974)', async function() { const level3Schema = new Schema({ name: { type: String } }); @@ -3854,42 +3840,34 @@ describe('model: populate:', function() { const level2 = db.model('Test1', level2Schema); const level1 = db.model('Test2', level1Schema); - const l3 = [ + let l3 = [ { name: 'level 3/1' }, { name: 'level 3/2' } ]; - level3.create(l3, function(error, l3) { - assert.ifError(error); - const l2 = [ - { name: 'level 2', level31: l3[0]._id, level32: l3[1]._id } - ]; - level2.create(l2, function(error, l2) { - assert.ifError(error); - const l1 = [{ name: 'level 1', level2: l2[0]._id }]; - level1.create(l1, function(error, l1) { - assert.ifError(error); - level1.findById(l1[0]._id). - populate({ - path: 'level2', - populate: [{ - path: 'level31' - }] - }). - populate({ - path: 'level2', - populate: [{ - path: 'level32' - }] - }). - exec(function(error, obj) { - assert.ifError(error); - assert.equal(obj.level2[0].level31[0].name, 'level 3/1'); - assert.equal(obj.level2[0].level32[0].name, 'level 3/2'); - done(); - }); - }); + l3 = await level3.create(l3); + + const l2 = await level2.create([ + { name: 'level 2', level31: l3[0]._id, level32: l3[1]._id } + ]); + + const l1 = await level1.create([{ name: 'level 1', level2: l2[0]._id }]); + + const obj = await level1.findById(l1[0]._id). + populate({ + path: 'level2', + populate: [{ + path: 'level31' + }] + }). + populate({ + path: 'level2', + populate: [{ + path: 'level32' + }] }); - }); + + assert.equal(obj.level2[0].level31[0].name, 'level 3/1'); + assert.equal(obj.level2[0].level32[0].name, 'level 3/2'); }); it('out-of-order discriminators (gh-4073)', function() { From 0698d9adec2758463a3b1676f8100faafe32748a Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 11:55:04 -0400 Subject: [PATCH 07/28] test: print error to debug why #3973 test only fails on Deno in GH workflows re: #9056 --- test/model.populate.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/model.populate.test.js b/test/model.populate.test.js index 03bd6b26af3..91b7f33d846 100644 --- a/test/model.populate.test.js +++ b/test/model.populate.test.js @@ -3798,7 +3798,10 @@ describe('model: populate:', function() { const l4 = await level4.create(l4docs); const l3docs = [{ name: 'level 3', level4: l4[0]._id }]; - const l3 = await level3.create(l3docs); + const l3 = await level3.create(l3docs).catch(err => { + console.log(err); + throw err; + }); const l2docs = [{ name: 'level 2', level3: l3[0]._id }]; const l2 = await level2.create(l2docs); From 356a13249795c20f958d0bb88c8b0e99f6fda5d9 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 12:22:28 -0400 Subject: [PATCH 08/28] test: print some more errors re: #9056 --- test/model.populate.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/model.populate.test.js b/test/model.populate.test.js index 91b7f33d846..7cf7e1902b4 100644 --- a/test/model.populate.test.js +++ b/test/model.populate.test.js @@ -3800,6 +3800,9 @@ describe('model: populate:', function() { const l3docs = [{ name: 'level 3', level4: l4[0]._id }]; const l3 = await level3.create(l3docs).catch(err => { console.log(err); + console.log(err?.errors); + console.log(err?.errors?.level4); + console.log(err?.errors?.level4?.reason); throw err; }); From 2bcebe00bf21a963fa962accff59f7cc99a46e49 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 12:27:21 -0400 Subject: [PATCH 09/28] avoid using elvis operator --- test/model.populate.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/model.populate.test.js b/test/model.populate.test.js index 7cf7e1902b4..5eb732cc3ff 100644 --- a/test/model.populate.test.js +++ b/test/model.populate.test.js @@ -3800,9 +3800,9 @@ describe('model: populate:', function() { const l3docs = [{ name: 'level 3', level4: l4[0]._id }]; const l3 = await level3.create(l3docs).catch(err => { console.log(err); - console.log(err?.errors); - console.log(err?.errors?.level4); - console.log(err?.errors?.level4?.reason); + console.log(err.errors); + console.log(err.errors.level4); + console.log(err.errors.level4.reason); throw err; }); From 79fb5b2677dceed2f152266eb2564cd27c6d7b71 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 12:34:01 -0400 Subject: [PATCH 10/28] test: try cleaning up castNonArrays option to fix Deno tests re: #9056 --- test/types.array.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/types.array.test.js b/test/types.array.test.js index 68d5b2dcd0f..69f7fe81a19 100644 --- a/test/types.array.test.js +++ b/test/types.array.test.js @@ -1160,7 +1160,7 @@ describe('types array', function() { }); }); - describe('options', function() { + describe.skip('options', function() { let arrOptions; let docArrOptions; @@ -2166,7 +2166,7 @@ describe('types array', function() { assert.strictEqual(arr[0], 42); }); - it('test "castNonArrays" property option', function() { + it.skip('test "castNonArrays" property option', function() { const Model = db.model('Test', new Schema({ x1: { castNonArrays: false, type: [String] }, x2: { castNonArrays: true, type: [String] }, x3: { type: [String] } })); const string = 'hello'; @@ -2205,5 +2205,7 @@ describe('types array', function() { // Assert assert.ifError(user.validateSync()); + + delete m.Schema.Types.Array.options.castNonArrays; }); }); From f89f8332acdbc3c769beea0aa46dfdd2a61817a3 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 12:39:59 -0400 Subject: [PATCH 11/28] test: correctly reset castNonArrays --- test/types.array.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/types.array.test.js b/test/types.array.test.js index 69f7fe81a19..010b173a5f9 100644 --- a/test/types.array.test.js +++ b/test/types.array.test.js @@ -1160,7 +1160,7 @@ describe('types array', function() { }); }); - describe.skip('options', function() { + describe('options', function() { let arrOptions; let docArrOptions; @@ -2166,7 +2166,7 @@ describe('types array', function() { assert.strictEqual(arr[0], 42); }); - it.skip('test "castNonArrays" property option', function() { + it('test "castNonArrays" property option', function() { const Model = db.model('Test', new Schema({ x1: { castNonArrays: false, type: [String] }, x2: { castNonArrays: true, type: [String] }, x3: { type: [String] } })); const string = 'hello'; @@ -2206,6 +2206,6 @@ describe('types array', function() { // Assert assert.ifError(user.validateSync()); - delete m.Schema.Types.Array.options.castNonArrays; + m.Schema.Types.Array.options.castNonArrays = true; }); }); From 5045b5b95611dd4e7d83c96df867187f0c702bed Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 12:51:33 -0400 Subject: [PATCH 12/28] test: skip child_process test in Deno, explicitly exit when tests are done re: #9056 --- package.json | 2 +- test/deno.js | 1 + test/errors.validation.test.js | 5 +++++ test/query.test.js | 1 - 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3360a3ccc8c..4b98cd2d7ca 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ ], "license": "MIT", "dependencies": { - "bson": "^4.6.5", + "bson": "^4.7.0", "kareem": "2.4.1", "mongodb": "4.9.1", "mpath": "0.9.0", diff --git a/test/deno.js b/test/deno.js index a13618ae410..672556569a7 100644 --- a/test/deno.js +++ b/test/deno.js @@ -30,4 +30,5 @@ for (const file of files) { mocha.run(function(failures) { process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures + process.exit(process.exitCode); }); \ No newline at end of file diff --git a/test/errors.validation.test.js b/test/errors.validation.test.js index b881d4bf80a..e778c126208 100644 --- a/test/errors.validation.test.js +++ b/test/errors.validation.test.js @@ -234,6 +234,11 @@ describe('ValidationError', function() { describe('when user code defines a r/o Error#toJSON', function() { it('should not fail', function(done) { + if (typeof Deno !== 'undefined') { + // Deno doesn't support child_process.fork + return this.skip(); + } + const err = []; const child = require('child_process') .fork('./test/isolated/project-has-error.toJSON.js', ['--no-warnings'], { silent: true }); diff --git a/test/query.test.js b/test/query.test.js index fc1ad0b4080..dc26ca44fd8 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -3478,7 +3478,6 @@ describe('Query', function() { const userSchema = Schema({ token: String }); const User = db.model('Test', userSchema); - const original = await User.create({ token: 'rightToken' }); let doc = await User.findOne({ token: 'wrongToken', _bsontype: 'a' }); assert.ok(!doc); From c13f2a66bf8a7ba9ba71863e8aab50f36d41cca0 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 13:03:17 -0400 Subject: [PATCH 13/28] test: check if #8222 error is caught in Deno re: #9056 --- test/model.populate.test.js | 3 --- test/query.test.js | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/model.populate.test.js b/test/model.populate.test.js index 5eb732cc3ff..91b7f33d846 100644 --- a/test/model.populate.test.js +++ b/test/model.populate.test.js @@ -3800,9 +3800,6 @@ describe('model: populate:', function() { const l3docs = [{ name: 'level 3', level4: l4[0]._id }]; const l3 = await level3.create(l3docs).catch(err => { console.log(err); - console.log(err.errors); - console.log(err.errors.level4); - console.log(err.errors.level4.reason); throw err; }); diff --git a/test/query.test.js b/test/query.test.js index dc26ca44fd8..dec6c135e44 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -3479,7 +3479,10 @@ describe('Query', function() { const User = db.model('Test', userSchema); const original = await User.create({ token: 'rightToken' }); - let doc = await User.findOne({ token: 'wrongToken', _bsontype: 'a' }); + + let doc = await User.findOne({ token: 'wrongToken', _bsontype: 'a' }).catch(err => { + console.log('Caught', err, err instanceof Error); + }); assert.ok(!doc); doc = await User.findOne(original._id); From d6f6ce8a282f012c05ba4a852d69898c023c36d2 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 13:32:34 -0400 Subject: [PATCH 14/28] test: temporarily skip strictQuery tests to see if they fix #9056 test failure --- .github/workflows/test.yml | 1 + test/query.test.js | 4 +--- test/schema.test.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6c2dc7af353..7fd517eb6d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -115,6 +115,7 @@ jobs: uses: denoland/setup-deno@v1 with: deno-version: v1.25.x + - run: deno --version - run: npm install - name: Run Deno tests run: npm run test-deno diff --git a/test/query.test.js b/test/query.test.js index dec6c135e44..0058fdeb2af 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -3480,9 +3480,7 @@ describe('Query', function() { const original = await User.create({ token: 'rightToken' }); - let doc = await User.findOne({ token: 'wrongToken', _bsontype: 'a' }).catch(err => { - console.log('Caught', err, err instanceof Error); - }); + let doc = await User.findOne({ token: 'wrongToken', _bsontype: 'a' }); assert.ok(!doc); doc = await User.findOne(original._id); diff --git a/test/schema.test.js b/test/schema.test.js index 0a994b87398..0ef15184f32 100644 --- a/test/schema.test.js +++ b/test/schema.test.js @@ -2442,7 +2442,7 @@ describe('schema', function() { assert.ok(!schema.virtuals.id); }); - describe('mongoose.set(`strictQuery`, value); (gh-6658)', function() { + describe.skip('mongoose.set(`strictQuery`, value); (gh-6658)', function() { let strictQueryOriginalValue; this.beforeEach(() => strictQueryOriginalValue = mongoose.get('strictQuery')); From 72124b88cc889918e904e4c769b751f382ad3df9 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 13:38:17 -0400 Subject: [PATCH 15/28] test: increase test timeout in deno and ensure strictQuery is set re: #9056 --- test/deno.js | 1 + test/query.test.js | 2 +- test/schema.test.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/deno.js b/test/deno.js index 672556569a7..3ab43861f14 100644 --- a/test/deno.js +++ b/test/deno.js @@ -12,6 +12,7 @@ const fs = require('fs'); const path = require('path'); const mocha = new Mocha({ + timeout: 8000, ...(args.g ? { fgrep: '' + args.g } : {}) }); diff --git a/test/query.test.js b/test/query.test.js index 0058fdeb2af..3bc8a1484f9 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -3475,7 +3475,7 @@ describe('Query', function() { }); it('query with top-level _bsontype (gh-8222) (gh-8268)', async function() { - const userSchema = Schema({ token: String }); + const userSchema = Schema({ token: String }, { strictQuery: true }); const User = db.model('Test', userSchema); const original = await User.create({ token: 'rightToken' }); diff --git a/test/schema.test.js b/test/schema.test.js index 0ef15184f32..0a994b87398 100644 --- a/test/schema.test.js +++ b/test/schema.test.js @@ -2442,7 +2442,7 @@ describe('schema', function() { assert.ok(!schema.virtuals.id); }); - describe.skip('mongoose.set(`strictQuery`, value); (gh-6658)', function() { + describe('mongoose.set(`strictQuery`, value); (gh-6658)', function() { let strictQueryOriginalValue; this.beforeEach(() => strictQueryOriginalValue = mongoose.get('strictQuery')); From b3c31f180081be841dcbf4b27aeeb77adc5962c6 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 13:49:43 -0400 Subject: [PATCH 16/28] test: add back connection and index tests, skip because of dns issue #9056 --- test/connection.test.js | 4 ++++ test/deno.js | 2 +- test/index.test.js | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/connection.test.js b/test/connection.test.js index b6fad70087d..113d394d46b 100644 --- a/test/connection.test.js +++ b/test/connection.test.js @@ -886,6 +886,10 @@ describe('connections:', function() { }); it('throws a MongooseServerSelectionError on server selection timeout (gh-8451)', () => { + if (typeof Deno !== 'undefined') { + // In Deno dns throws an uncatchable error here. + return this.skip(); + } const opts = { serverSelectionTimeoutMS: 100 }; diff --git a/test/deno.js b/test/deno.js index 3ab43861f14..22bd3362b02 100644 --- a/test/deno.js +++ b/test/deno.js @@ -19,7 +19,7 @@ const mocha = new Mocha({ const testDir = 'test'; const files = fs.readdirSync(testDir); -const ignoreFiles = new Set(['browser.test.js', 'connection.test.js', 'index.test.js']); +const ignoreFiles = new Set(['browser.test.js']); for (const file of files) { if (!file.endsWith('.test.js') || ignoreFiles.has(file)) { diff --git a/test/index.test.js b/test/index.test.js index b67aee31763..683e8136b2f 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -845,6 +845,11 @@ describe('mongoose module:', function() { }); it('connect with url doesnt cause unhandled rejection (gh-6997)', async function() { + if (typeof Deno !== 'undefined') { + // In Deno dns throws an uncatchable error here. + return this.skip(); + } + const m = new mongoose.Mongoose(); const _options = Object.assign({}, options, { serverSelectionTimeoutMS: 100 }); const error = await m.connect('mongodb://doesnotexist:27009/test', _options).then(() => null, err => err); From 1fb268ef62c921c3f0090a9ba8f044f3daad627d Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 13:54:47 -0400 Subject: [PATCH 17/28] test: quick test fix re: #9046 --- test/connection.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/connection.test.js b/test/connection.test.js index 113d394d46b..02779f18767 100644 --- a/test/connection.test.js +++ b/test/connection.test.js @@ -885,7 +885,7 @@ describe('connections:', function() { return Model.create({ name: 'test' }); }); - it('throws a MongooseServerSelectionError on server selection timeout (gh-8451)', () => { + it('throws a MongooseServerSelectionError on server selection timeout (gh-8451)', function() { if (typeof Deno !== 'undefined') { // In Deno dns throws an uncatchable error here. return this.skip(); From 17e28318ccedf8c0a9699c74d200ad4539eb8f3d Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 5 Sep 2022 13:59:54 -0400 Subject: [PATCH 18/28] test: correctly clean up model re: #9056 --- test/connection.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/connection.test.js b/test/connection.test.js index 02779f18767..d1edc428df1 100644 --- a/test/connection.test.js +++ b/test/connection.test.js @@ -271,6 +271,7 @@ describe('connections:', function() { }); it('allows passing a schema', function() { + mongoose.deleteModel(/Test/); const MyModel = mongoose.model('Test', new Schema({ name: String })); From 66d8cad8a29e86e29f9b0d8b3dcdd59d0d9ab25e Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 3 Oct 2022 16:24:53 -0400 Subject: [PATCH 19/28] test: proof of concept for running Mongoose tests without --unstable --- package.json | 2 +- test/deno.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c70afc91d6c..40e97ca9a10 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "release-legacy": "git pull origin 5.x && git push origin 5.x --tags && npm publish --tag legacy", "mongo": "node ./tools/repl.js", "test": "mocha --exit ./test/*.test.js", - "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --unstable ./test/deno.js", + "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run ./test/deno.js", "test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit ./test/*.test.js", "test-tsd": "node ./test/types/check-types-filename && tsd", "tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}", diff --git a/test/deno.js b/test/deno.js index 22bd3362b02..9a0a9423b4d 100644 --- a/test/deno.js +++ b/test/deno.js @@ -2,11 +2,23 @@ import { createRequire } from "https://deno.land/std/node/module.ts"; +// Workaround for Mocha getting terminal width, which currently requires `--unstable` +Object.defineProperty(process.stdout, 'getWindowSize', { + value: function() { + return [75, 40]; + } +}); + import { parse } from "https://deno.land/std/flags/mod.ts" const args = parse(Deno.args); const require = createRequire(import.meta.url); +// Workaround for MongoDB getting the current os release, which currently requires `--unstable` +require('os').release = function() { + return 'deno test'; +}; + const Mocha = require('mocha'); const fs = require('fs'); const path = require('path'); From cdc824dac2f0bfb1abb368f814e166b5d08b455f Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 3 Oct 2022 16:35:45 -0400 Subject: [PATCH 20/28] chore: test with deno v1.26.x --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0df7c1b4686..c46003da46f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -109,7 +109,7 @@ jobs: - name: Setup Deno uses: denoland/setup-deno@v1 with: - deno-version: v1.25.x + deno-version: v1.26.x - run: deno --version - run: npm install - name: Run Deno tests From 72bf47b3025da5c1d384368580a15749b0f433bd Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 3 Oct 2022 16:51:00 -0400 Subject: [PATCH 21/28] test: add missing test files to deno --- test/deno.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/deno.js b/test/deno.js index 9a0a9423b4d..00382224731 100644 --- a/test/deno.js +++ b/test/deno.js @@ -29,7 +29,9 @@ const mocha = new Mocha({ }); const testDir = 'test'; -const files = fs.readdirSync(testDir); +const files = fs.readdirSync(testDir). + concat(fs.readdirSync(path.join(testDir, 'docs')).map(file => path.join('docs', file))). + concat(fs.readdirSync(path.join(testDir, 'helpers')).map(file => path.join('helpers', file))); const ignoreFiles = new Set(['browser.test.js']); From 759e47d69dce73582626f86bdf65c261a5dfa111 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 5 Oct 2022 16:57:57 -0400 Subject: [PATCH 22/28] docs: add deno instructions and badges to README --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60da3ccde9f..0cf93d883f8 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Mongoose -Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment. Mongoose supports both promises and callbacks. +Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment. Mongoose supports [Node.js](https://nodejs.org/en/) and [Deno](https://deno.land/) (beta). -[![Slack Status](https://img.shields.io/badge/slack-mongoosejsteam-34D058.svg?logo=slack )](https://mongoosejsteam.slack.com) [![Build Status](https://github.com/Automattic/mongoose/workflows/Test/badge.svg)](https://github.com/Automattic/mongoose) [![NPM version](https://badge.fury.io/js/mongoose.svg)](http://badge.fury.io/js/mongoose) +[![Deno version](https://deno.land/badge/mongoose/version)](https://deno.land/x/mongoose) +[![Deno popularity](https://deno.land/badge/mongoose/popularity)](https://deno.land/x/mongoose) [![npm](https://nodei.co/npm/mongoose.png)](https://www.npmjs.com/package/mongoose) @@ -45,6 +46,8 @@ First install [Node.js](http://nodejs.org/) and [MongoDB](https://www.mongodb.or $ npm install mongoose ``` +Mongoose 6.7.0 also includes beta support for [Deno](https://deno.land/). + ## Importing ```javascript @@ -55,6 +58,15 @@ const mongoose = require('mongoose'); import mongoose from 'mongoose'; ``` +Or, using [Deno's `createRequire()` for CommonJS support](https://deno.land/std@0.113.0/node/README.md?source=#commonjs-modules-loading) as follows. + +```javascript +import { createRequire } from 'https://deno.land/std/node/module.ts'; +const require = createRequire(import.meta.url); + +const mongoose = require('mongoose'); +``` + ## Mongoose for Enterprise Available as part of the Tidelift Subscription From 872b9a3298d43ae4ff34a6d6b038fbb245c0f845 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 5 Oct 2022 17:01:42 -0400 Subject: [PATCH 23/28] docs: more info on required deno flags --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0cf93d883f8..427a967d98e 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,19 @@ import mongoose from 'mongoose'; Or, using [Deno's `createRequire()` for CommonJS support](https://deno.land/std@0.113.0/node/README.md?source=#commonjs-modules-loading) as follows. ```javascript -import { createRequire } from 'https://deno.land/std/node/module.ts'; +import { createRequire } from "https://deno.land/std/node/module.ts"; const require = createRequire(import.meta.url); const mongoose = require('mongoose'); + +mongoose.connect('mongodb://localhost:27017/test') + .then(() => console.log('Connected!')); +``` + +You can then run the above script using the following. + +``` +deno run --allow-env --allow-read --allow-net mongoose-test.js ``` ## Mongoose for Enterprise From bd5e28ae92a37ec3afaf626f41d024b74613d75a Mon Sep 17 00:00:00 2001 From: Uzlopak Date: Fri, 28 Oct 2022 20:44:20 +0200 Subject: [PATCH 24/28] Apply suggestions from code review --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c46003da46f..4b7c9ebaf07 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -109,7 +109,7 @@ jobs: - name: Setup Deno uses: denoland/setup-deno@v1 with: - deno-version: v1.26.x + deno-version: v1.27.x - run: deno --version - run: npm install - name: Run Deno tests From e4e26f15a64defb050632b7552b61b18d420bfd3 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 28 Nov 2022 12:11:55 -0500 Subject: [PATCH 25/28] Update README.md Co-authored-by: Uzlopak --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 427a967d98e..a159210081f 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ First install [Node.js](http://nodejs.org/) and [MongoDB](https://www.mongodb.or $ npm install mongoose ``` -Mongoose 6.7.0 also includes beta support for [Deno](https://deno.land/). +Mongoose 6.8.0 also includes beta support for [Deno](https://deno.land/). ## Importing From 0a3723232ac5c1a3580542e4c2935a2c78d67ca2 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 28 Nov 2022 12:21:01 -0500 Subject: [PATCH 26/28] fix: use deno 1.28 in tests, use --allow-sys, no more --unstable --- .github/workflows/test.yml | 2 +- README.md | 2 +- package.json | 2 +- test/deno.js | 5 ----- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e2c798def6..d362114672d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -109,7 +109,7 @@ jobs: - name: Setup Deno uses: denoland/setup-deno@v1 with: - deno-version: v1.27.x + deno-version: v1.28.x - run: deno --version - run: npm install - name: Run Deno tests diff --git a/README.md b/README.md index a159210081f..0d27b549e46 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ mongoose.connect('mongodb://localhost:27017/test') You can then run the above script using the following. ``` -deno run --allow-env --allow-read --allow-net mongoose-test.js +deno run --allow-net --allow-read --allow-sys --allow-env mongoose-test.js ``` ## Mongoose for Enterprise diff --git a/package.json b/package.json index 4737725fd2b..5018f58c812 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "release-legacy": "git pull origin 5.x && git push origin 5.x --tags && npm publish --tag legacy", "mongo": "node ./tools/repl.js", "test": "mocha --exit ./test/*.test.js", - "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run ./test/deno.js", + "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --allow-sys ./test/deno.js", "test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit ./test/*.test.js", "test-tsd": "node ./test/types/check-types-filename && tsd", "tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}", diff --git a/test/deno.js b/test/deno.js index 00382224731..922766f1b20 100644 --- a/test/deno.js +++ b/test/deno.js @@ -14,11 +14,6 @@ const args = parse(Deno.args); const require = createRequire(import.meta.url); -// Workaround for MongoDB getting the current os release, which currently requires `--unstable` -require('os').release = function() { - return 'deno test'; -}; - const Mocha = require('mocha'); const fs = require('fs'); const path = require('path'); From b41f2de5eeacb73fa34697784f4a346bc18e8e05 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 28 Nov 2022 12:27:56 -0500 Subject: [PATCH 27/28] test: clear data between query cursor tests --- test/query.cursor.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/query.cursor.test.js b/test/query.cursor.test.js index 575d06e79b6..6f22c0eab4d 100644 --- a/test/query.cursor.test.js +++ b/test/query.cursor.test.js @@ -27,13 +27,14 @@ describe('QueryCursor', function() { afterEach(() => require('./util').clearTestData(db)); afterEach(() => require('./util').stopRemainingOps(db)); - beforeEach(function() { + beforeEach(async function() { const schema = new Schema({ name: String }); schema.virtual('test').get(function() { return 'test'; }); Model = db.model('Test', schema); - return Model.create({ name: 'Axl' }, { name: 'Slash' }); + await Model.deleteMany({}); + await Model.create({ name: 'Axl' }, { name: 'Slash' }); }); describe('#next()', function() { From 68ec07d1c2cd76024480de816aad19065c862552 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 28 Nov 2022 12:57:38 -0500 Subject: [PATCH 28/28] quick note about alpha support for deno --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0d27b549e46..10d443f45ab 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mongoose -Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment. Mongoose supports [Node.js](https://nodejs.org/en/) and [Deno](https://deno.land/) (beta). +Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment. Mongoose supports [Node.js](https://nodejs.org/en/) and [Deno](https://deno.land/) (alpha). [![Build Status](https://github.com/Automattic/mongoose/workflows/Test/badge.svg)](https://github.com/Automattic/mongoose) [![NPM version](https://badge.fury.io/js/mongoose.svg)](http://badge.fury.io/js/mongoose) @@ -46,7 +46,7 @@ First install [Node.js](http://nodejs.org/) and [MongoDB](https://www.mongodb.or $ npm install mongoose ``` -Mongoose 6.8.0 also includes beta support for [Deno](https://deno.land/). +Mongoose 6.8.0 also includes alpha support for [Deno](https://deno.land/). ## Importing