Notes while taking M220JS: MongoDB for Javascript Developers - Learn the essentials of Node.js application development with MongoDB.
- Chapter 0: Introduction and Setup
- Chapter 1: Driver Setup
- Chapter 2: User-Facing Backend
- Chapter 3: Admin Backend
- Chapter 4: Resiliency
- Final Exam
Chapter 1: Driver Setup
Test database connection
PS F:\Projects\mflix-js> npm test -t db-connection
> server@1.0.0 test F:\Projects\mflix-js
> jest --passWithNoTests "db-connection"
Determining test suites to run...Setup Mongo Connection
PASS test/db-connection.test.js
Connection
√ Can access MFlix data (360ms)
√ Can retrieve a movie by id (60ms)
√ Can retrieve first page of movies (267ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 3.337s, estimated 4s
Ran all test suites matching /db-connection/i.
Teardown Mongo Connection
PS F:\Projects\mflix-js>
Ticket: Projection
PS F:\Projects\mflix-js> npm test -t projection
> server@1.0.0 test F:\Projects\mflix-js
> jest --passWithNoTests "projection"
Determining test suites to run...Setup Mongo Connection
console.log src/dao/moviesDAO.js:58
Passed argument countries: Kosovo
console.log src/dao/moviesDAO.js:58
Passed argument countries: Russia,Japan,Mexico
PASS test/projection.test.js (5.994s)
Projection
√ Can perform a country search for one country (643ms)
√ Can perform a country search for three countries (781ms)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 6.566s, estimated 9s
Ran all test suites matching /projection/i.
Teardown Mongo Connection
PS F:\Projects\mflix-js>
Ticket: Text and Subfield Search
PS F:\Projects\mflix-js> npm test -t text-subfield
> server@1.0.0 test F:\Projects\mflix-js
> jest --passWithNoTests "text-subfield"
Determining test suites to run...Setup Mongo Connection
PASS test/text-subfield.test.js (5.126s)
Text and Subfield Search
√ Can perform a text search (481ms)
√ Can perform a genre search with one genre (371ms)
√ Can perform a genre search with multiple genres (281ms)
√ Can perform a cast search with one cast member (171ms)
√ Can perform a cast search with multiple cast members (275ms)
√ Can perform a search and return a non-default number of movies per page (403ms)
Test Suites: 1 passed, 1 total
Tests: 6 passed, 6 total
Snapshots: 0 total
Time: 5.711s
Ran all test suites matching /text-subfield/i.
Teardown Mongo Connection
PS F:\Projects\mflix-js>
Chapter 2: User-Facing Backend
Ticket: Paging
PS D:\projects\mflix-js> npm test -t paging
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "paging"
Determining test suites to run...Setup Mongo Connection
PASS test/paging.test.js (6.534s)
Paging
√ Supports paging by cast (1534ms)
√ Supports paging by genre (837ms)
√ Supports paging by text (223ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 7.138s
Ran all test suites matching /paging/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Ticket: Faceted Search
PS D:\projects\mflix-js> npm test -t facets
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "facets"
Determining test suites to run...Setup Mongo Connection
PASS test/facets.test.js
Facets
√ should require cast members to perform search with (3ms)
√ should return movies and runtime/rating facets for returned movies (579ms)
√ should also support paging (199ms)
√ should throw an error if castMembers is empty (4ms)
Test Suites: 1 passed, 1 total
Tests: 4 passed, 4 total
Snapshots: 0 total
Time: 3.559s, estimated 6s
Ran all test suites matching /facets/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Ticket: User Management
PS D:\projects\mflix-js> npm test -t user-management
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "user-management"
Determining test suites to run...Setup Mongo Connection
PASS test/user-management.test.js
User Management
√ it can add a new user to the database (613ms)
√ it returns an error when trying to register duplicate user (64ms)
√ it allows a user to login (236ms)
√ it allows a user to logout (130ms)
Test Suites: 1 passed, 1 total
Tests: 4 passed, 4 total
Snapshots: 0 total
Time: 5.441s
Ran all test suites matching /user-management/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Ticket: User Preferences
PS D:\projects\mflix-js> npm test -t user-preferences
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "user-preferences"
Determining test suites to run...Setup Mongo Connection
PASS test/user-preferences.test.js (5.258s)
User Preferences
√ Invalid user should not have preferences (817ms)
√ Null preferences should be valid (180ms)
√ Valid preferences are reflected in DB (296ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 6.103s
Ran all test suites matching /user-preferences/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Ticket: Get Comments
PS D:\projects\mflix-js> npm test -t get-comments
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "get-comments"
Determining test suites to run...Setup Mongo Connection
PASS test/get-comments.test.js (5.274s)
Get Comments
√ Can fetch comments for a movie (573ms)
√ comments should be sorted by date (126ms)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 6.203s
Ran all test suites matching /get-comments/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Ticket: Create/Update Comments
PS D:\projects\mflix-js> npm test -t create-update-comments
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "create-update-comments"
Determining test suites to run...Setup Mongo Connection
PASS test/create-update-comments.test.js
Create/Update Comments
√ Can post a comment (342ms)
√ Can update a comment (119ms)
√ Can only update comment if user posted comment (31ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 3.342s, estimated 5s
Ran all test suites matching /create-update-comments/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Ticket: Delete Comments
PS D:\projects\mflix-js> npm test -t delete-comments
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "delete-comments"
Determining test suites to run...Setup Mongo Connection
PASS test/delete-comments.test.js
Delete Comments
√ Can post a comment (652ms)
√ Cannot delete a comment if email does not match (114ms)
√ Can delete a comment if email matches (59ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 5.274s
Ran all test suites matching /delete-comments/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Chapter 3: Admin Backend
Ticket: User Report
PS D:\projects\mflix-js> npm test -t user-report
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "user-report"
Determining test suites to run...Setup Mongo Connection
PASS test/user-report.test.js (5.719s)
User Report
√ Should return exactly twenty results (1259ms)
√ Should return correct comment totals (604ms)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 6.345s
Ran all test suites matching /user-report/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Ticket: Migration
PS D:\projects\mflix-js> node .\src\migrations\movie-last-updated-migration.js Found 23539 documents to update 23539 documents updated PS D:\projects\mflix-js>
PS D:\projects\mflix-js> npm test -t migration
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "migration"
Determining test suites to run...Setup Mongo Connection
PASS test/migration.test.js (6.246s)
Migration
√ migration (384ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 7.461s
Ran all test suites matching /migration/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Chapter 4: Resiliency
Ticket: Connection Pooling
PS D:\projects\mflix-js> npm test -t connection-pooling
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "connection-pooling"
Determining test suites to run...Setup Mongo Connection
(node:13736) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true }
to the MongoClient constructor.
PASS test/connection-pooling.test.js
Connection Pooling
√ Connection pool size is 50 (57ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 5.079s
Ran all test suites matching /connection-pooling/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
Ticket: Timeouts
PS D:\projects\mflix-js> npm test -t timeouts
> server@1.0.0 test D:\projects\mflix-js
> jest --passWithNoTests "timeouts"
Determining test suites to run...Setup Mongo Connection
PASS test/timeouts.test.js
Timeouts
√ Timeout is set to 2500 milliseconds (281ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.463s
Ran all test suites matching /timeouts/i.
Teardown Mongo Connection
PS D:\projects\mflix-js>
