There are few mocha tests which needs to be migrated to Jest.
Following test cases should be converted to jest.
╰─ yarn test:mocha ─╯
yarn run v1.22.10
$ node scripts/mocha
dev/File
constructor
✓ throws if path is not a string
#getRelativePath()
✓ returns the path relative to the repo root
#isJs()
✓ returns true if extension is .js
✓ returns false if extension is .xml
✓ returns false if extension is .css
✓ returns false if extension is .html
✓ returns false if file has no extension
#getRelativeParentDirs()
✓ returns the parents of a file, stopping at the repo root, in descending order
#toString()
✓ returns the relativePath
#toJSON()
✓ returns the relativePath
All configs should use a single version of Node
✓ should compare .node-version and .nvmrc
✓ should compare .node-version and engines.node from package.json
getUrl
✓ should convert to a url
✓ should convert to a url with port
✓ should convert to a secure hashed url
tasks/lib/licenses
assertLicensesValid()
✓ returns undefined when package has valid license
✓ throw an error when the packages license is invalid
✓ throws an error when the package has no licenses
✓ includes the relative path to packages in error message
dev/mocha/junit report generation
✓ reports on failed setup hooks
unset(obj, key)
invalid input
✓ should do nothing if not given an object
✓ should do nothing if not given a key
✓ should do nothing if given an empty string as a key
shallow removal
✓ should remove the param using a string key
✓ should remove the param using an array key
deep removal
✓ should remove the param using a string key
✓ should remove the param using an array key
recursive removal
✓ should clear object if only value is removed
✓ should clear object if no props are left
✓ should remove deep property, then clear the object
plugins/console
#getOpenSearchProxyConfig
✓ sets timeout
✓ uses https.Agent when url's protocol is https
✓ uses http.Agent when url's protocol is http
ssl
✓ sets rejectUnauthorized to false when verificationMode is none
✓ sets rejectUnauthorized to true when verificationMode is certificate
✓ sets checkServerIdentity to not check hostname when verificationMode is certificate
✓ sets rejectUnauthorized to true when verificationMode is full
✓ doesn't set checkServerIdentity when verificationMode is full
✓ sets ca when certificateAuthorities are specified
when alwaysPresentCertificate is false
✓ doesn't set cert and key when certificate and key paths are specified
✓ doesn't set passphrase when certificate, key and keyPassphrase are specified
when alwaysPresentCertificate is true
✓ sets cert and key when certificate and key are specified
✓ sets passphrase when certificate, key and keyPassphrase are specified
✓ doesn't set cert when only certificate path is specified
✓ doesn't set key when only key path is specified
ProxyConfig
constructor
✓ uses ca to create sslAgent
✓ uses cert, and key to create sslAgent
✓ uses ca, cert, and key to create sslAgent
#getForParsedUri
parsed url does not match
✓ returns {}
parsed url does match
✓ assigns timeout value
✓ assigns ssl.verify to rejectUnauthorized
uri us http
ca is set
✓ creates but does not output the agent
cert is set
✓ creates but does not output the agent
key is set
✓ creates but does not output the agent
cert + key are set
✓ creates but does not output the agent
uri us https
ca is set
✓ creates and outputs the agent
cert is set
✓ creates and outputs the agent
key is set
✓ creates and outputs the agent
cert + key are set
✓ creates and outputs the agent
ProxyConfigCollection
http://localhost:5601
✓ defaults to the first matching timeout
https://localhost:5601/.opensearch_dashboards
✓ defaults to the first matching timeout
http://localhost:5602
✓ defaults to the first matching timeout
https://localhost:5602
✓ defaults to the first matching timeout
http://localhost:5603
✓ defaults to the first matching timeout
https://localhost:5603
✓ defaults to the first matching timeout
https://localhost:5601/index
✓ defaults to the first matching timeout
http://localhost:5601/index
✓ defaults to the first matching timeout
https://localhost:5601/index/type
✓ defaults to the first matching timeout
http://notlocalhost
✓ defaults to the first matching timeout
collection with ssl config and root level verify:false
✓ verifies for config that produces ssl agent
✓ disabled verification for * config
#set_headers
✓ throws if not given an object as the first argument
✓ throws if not given an object as the second argument
✓ returns a new object
✓ returns object with newHeaders merged with originalHeaders
✓ returns object where newHeaders takes precedence for any matching keys
WildcardMatcher
pattern = *
✓ matches http
✓ matches https
✓ matches nothing
✓ does not match /
✓ matches localhost
✓ matches a path
defaultValue = /
✓ matches /
pattern = http
✓ matches http
✓ does not match https
✓ does not match nothing
✓ does not match localhost
✓ does not match a path
pattern = 560{1..9}
✓ does not match http
✓ does not matches 5600
✓ matches 5601
✓ matches 5602
✓ matches 5603
✓ matches 5604
✓ matches 5605
✓ matches 5606
✓ matches 5607
✓ matches 5608
✓ matches 5609
✓ does not matches 5610
dateMath
errors
✓ should return undefined if passed something falsy
✓ should return undefined if I pass an operator besides [+-/]
✓ should return undefined if I pass a unit besidess,m,h,d,w,M,y,ms
✓ should return undefined if rounding unit is not 1
✓ should not go into an infinite loop when missing a unit
forceNow
✓ should throw an Error if passed a string
✓ should throw an Error if passed a moment
✓ should throw an Error if passed an invalid date
objects and strings
✓ should return the same moment if passed a moment
✓ should return a moment if passed a date
✓ should return a moment if passed an ISO8601 string
✓ should return the current time when parsing now
✓ should use the forceNow parameter when parsing now
subtraction
✓ should return 5s ago
✓ should return 5s before 2014-01-01T06:06:06.666Z
✓ should return 5s before forceNow
✓ should return 5m ago
✓ should return 5m before 2014-01-01T06:06:06.666Z
✓ should return 5m before forceNow
✓ should return 5h ago
✓ should return 5h before 2014-01-01T06:06:06.666Z
✓ should return 5h before forceNow
✓ should return 5d ago
✓ should return 5d before 2014-01-01T06:06:06.666Z
✓ should return 5d before forceNow
✓ should return 5w ago
✓ should return 5w before 2014-01-01T06:06:06.666Z
✓ should return 5w before forceNow
✓ should return 5M ago
✓ should return 5M before 2014-01-01T06:06:06.666Z
✓ should return 5M before forceNow
✓ should return 5y ago
✓ should return 5y before 2014-01-01T06:06:06.666Z
✓ should return 5y before forceNow
✓ should return 5ms ago
✓ should return 5ms before 2014-01-01T06:06:06.666Z
✓ should return 5ms before forceNow
✓ should return 12s ago
✓ should return 12s before 2014-01-01T06:06:06.666Z
✓ should return 12s before forceNow
✓ should return 12m ago
✓ should return 12m before 2014-01-01T06:06:06.666Z
✓ should return 12m before forceNow
✓ should return 12h ago
✓ should return 12h before 2014-01-01T06:06:06.666Z
✓ should return 12h before forceNow
✓ should return 12d ago
✓ should return 12d before 2014-01-01T06:06:06.666Z
✓ should return 12d before forceNow
✓ should return 12w ago
✓ should return 12w before 2014-01-01T06:06:06.666Z
✓ should return 12w before forceNow
✓ should return 12M ago
✓ should return 12M before 2014-01-01T06:06:06.666Z
✓ should return 12M before forceNow
✓ should return 12y ago
✓ should return 12y before 2014-01-01T06:06:06.666Z
✓ should return 12y before forceNow
✓ should return 12ms ago
✓ should return 12ms before 2014-01-01T06:06:06.666Z
✓ should return 12ms before forceNow
✓ should return 247s ago
✓ should return 247s before 2014-01-01T06:06:06.666Z
✓ should return 247s before forceNow
✓ should return 247m ago
✓ should return 247m before 2014-01-01T06:06:06.666Z
✓ should return 247m before forceNow
✓ should return 247h ago
✓ should return 247h before 2014-01-01T06:06:06.666Z
✓ should return 247h before forceNow
✓ should return 247d ago
✓ should return 247d before 2014-01-01T06:06:06.666Z
✓ should return 247d before forceNow
✓ should return 247w ago
✓ should return 247w before 2014-01-01T06:06:06.666Z
✓ should return 247w before forceNow
✓ should return 247M ago
✓ should return 247M before 2014-01-01T06:06:06.666Z
✓ should return 247M before forceNow
✓ should return 247y ago
✓ should return 247y before 2014-01-01T06:06:06.666Z
✓ should return 247y before forceNow
✓ should return 247ms ago
✓ should return 247ms before 2014-01-01T06:06:06.666Z
✓ should return 247ms before forceNow
addition
✓ should return 5s from now
✓ should return 5s after 2014-01-01T06:06:06.666Z
✓ should return 5s after forceNow
✓ should return 5m from now
✓ should return 5m after 2014-01-01T06:06:06.666Z
✓ should return 5m after forceNow
✓ should return 5h from now
✓ should return 5h after 2014-01-01T06:06:06.666Z
✓ should return 5h after forceNow
✓ should return 5d from now
✓ should return 5d after 2014-01-01T06:06:06.666Z
✓ should return 5d after forceNow
✓ should return 5w from now
✓ should return 5w after 2014-01-01T06:06:06.666Z
✓ should return 5w after forceNow
✓ should return 5M from now
✓ should return 5M after 2014-01-01T06:06:06.666Z
✓ should return 5M after forceNow
✓ should return 5y from now
✓ should return 5y after 2014-01-01T06:06:06.666Z
✓ should return 5y after forceNow
✓ should return 5ms from now
✓ should return 5ms after 2014-01-01T06:06:06.666Z
✓ should return 5ms after forceNow
✓ should return 12s from now
✓ should return 12s after 2014-01-01T06:06:06.666Z
✓ should return 12s after forceNow
✓ should return 12m from now
✓ should return 12m after 2014-01-01T06:06:06.666Z
✓ should return 12m after forceNow
✓ should return 12h from now
✓ should return 12h after 2014-01-01T06:06:06.666Z
✓ should return 12h after forceNow
✓ should return 12d from now
✓ should return 12d after 2014-01-01T06:06:06.666Z
✓ should return 12d after forceNow
✓ should return 12w from now
✓ should return 12w after 2014-01-01T06:06:06.666Z
✓ should return 12w after forceNow
✓ should return 12M from now
✓ should return 12M after 2014-01-01T06:06:06.666Z
✓ should return 12M after forceNow
✓ should return 12y from now
✓ should return 12y after 2014-01-01T06:06:06.666Z
✓ should return 12y after forceNow
✓ should return 12ms from now
✓ should return 12ms after 2014-01-01T06:06:06.666Z
✓ should return 12ms after forceNow
✓ should return 247s from now
✓ should return 247s after 2014-01-01T06:06:06.666Z
✓ should return 247s after forceNow
✓ should return 247m from now
✓ should return 247m after 2014-01-01T06:06:06.666Z
✓ should return 247m after forceNow
✓ should return 247h from now
✓ should return 247h after 2014-01-01T06:06:06.666Z
✓ should return 247h after forceNow
✓ should return 247d from now
✓ should return 247d after 2014-01-01T06:06:06.666Z
✓ should return 247d after forceNow
✓ should return 247w from now
✓ should return 247w after 2014-01-01T06:06:06.666Z
✓ should return 247w after forceNow
✓ should return 247M from now
✓ should return 247M after 2014-01-01T06:06:06.666Z
✓ should return 247M after forceNow
✓ should return 247y from now
✓ should return 247y after 2014-01-01T06:06:06.666Z
✓ should return 247y after forceNow
✓ should return 247ms from now
✓ should return 247ms after 2014-01-01T06:06:06.666Z
✓ should return 247ms after forceNow
rounding
✓ should round now to the beginning of the s
✓ should round now to the beginning of forceNow's s
✓ should round now to the end of the s
✓ should round now to the end of forceNow's s
✓ should round now to the beginning of the m
✓ should round now to the beginning of forceNow's m
✓ should round now to the end of the m
✓ should round now to the end of forceNow's m
✓ should round now to the beginning of the h
✓ should round now to the beginning of forceNow's h
✓ should round now to the end of the h
✓ should round now to the end of forceNow's h
✓ should round now to the beginning of the d
✓ should round now to the beginning of forceNow's d
✓ should round now to the end of the d
✓ should round now to the end of forceNow's d
✓ should round now to the beginning of the w
✓ should round now to the beginning of forceNow's w
✓ should round now to the end of the w
✓ should round now to the end of forceNow's w
✓ should round now to the beginning of the M
✓ should round now to the beginning of forceNow's M
✓ should round now to the end of the M
✓ should round now to the end of forceNow's M
✓ should round now to the beginning of the y
✓ should round now to the beginning of forceNow's y
✓ should round now to the end of the y
✓ should round now to the end of forceNow's y
✓ should round now to the beginning of the ms
✓ should round now to the beginning of forceNow's ms
✓ should round now to the end of the ms
✓ should round now to the end of forceNow's ms
math and rounding
✓ should round to the nearest second with 0 value
✓ should subtract 17s, rounded to the nearest second
✓ should add 555ms, rounded to the nearest millisecond
✓ should subtract 555ms, rounded to the nearest second
✓ should round weeks to Sunday by default
✓ should round weeks based on the passed moment locale start of week setting
✓ should round up weeks based on the passed moment locale start of week setting
✓ should round relative to forceNow
✓ should parse long expressions
used momentjs instance
✓ should use the default moment instance if parameter not specified
✓ should not use default moment instance if parameter is specified
✓ should work with multiple different instances
✓ should use global instance after passing an instance
units
✓ should have units descending for unitsDesc
✓ should have units ascending for unitsAsc
testSubjSelector()
✓ converts subjectSelectors to cssSelectors
@osd/eslint/disallow-license-headers
valid
✓ /* license */
console.log('foo')
✓ // license
console.log('foo')
invalid
✓ console.log('foo')
✓ console.log('foo')
✓ console.log('foo')
✓ console.log('foo')
✓ console.log('foo')
@osd/eslint/no-restricted-paths
valid
✓ import a from "../client/a.js"
✓ const a = require("../client/a.js")
✓ import b from "../server/b.js"
✓ notrequire("../server/b.js")
✓ notrequire("../server/b.js")
✓ require("../server/b.js")
✓ import b from "../server/b.js"
✓ require("os")
✓ const d = require("./deep/d.js")
✓ const d = require("./deep/d.js")
✓ import { X } from "./index_patterns"
invalid
✓ export { b } from "../server/b.js"
✓ import b from "../server/b.js"
✓ import a from "../client/a"
import c from "./c"
✓ const b = require("../server/b.js")
✓ const b = require("../server/b.js")
✓ const d = require("./deep/d.js")
✓ const d = require("src/core/server/saved_objects")
✓ const d = require("ui/kfetch")
✓ const d = require("ui/kfetch/public/index")
✓ import { X } from "./index_patterns"
@osd/eslint/require-license-header
valid
✓ /* license */
console.log('foo')
✓ // license
console.log('foo')
invalid
✓ console.log('foo')
✓ console.log('foo')
✓ console.log('foo')
✓ console.log('foo')
✓ console.log('foo')
✓ console.log('foo')
✓
/* license */
console.log('foo')
✓ /* not license */
/* license */
console.log('foo')
opensearchArchiver: Stats
#skippedIndex(index)
✓ marks the index as skipped
✓ logs that the index was skipped
#deletedIndex(index)
✓ marks the index as deleted
✓ logs that the index was deleted
#createdIndex(index, [metadata])
✓ marks the index as created
✓ logs that the index was created
with metadata
✓ debug-logs each key from the metadata
without metadata
✓ no debug logging
#archivedIndex(index, [metadata])
✓ marks the index as archived
✓ logs that the index was archived
with metadata
✓ debug-logs each key from the metadata
without metadata
✓ no debug logging
#indexedDoc(index)
✓ increases the docs.indexed count for the index
#archivedDoc(index)
✓ increases the docs.archived count for the index
#toJSON()
✓ returns the stats for all indexes
✓ returns a deep clone of the stats
#forEachIndex(fn)
✓ iterates a clone of the index stats
opensearchArchiver createFormatArchiveStreams
{ gzip: false }
✓ returns an array of streams
✓ streams consume js values and produces buffers
✓ product is pretty-printed JSON separated by two newlines
{ gzip: true }
✓ returns an array of streams
✓ streams consume js values and produces buffers
✓ output can be gunzipped
defaults
✓ product is not gzipped
opensearchArchiver createParseArchiveStreams
{ gzip: false }
✓ returns an array of streams
streams
✓ consume buffers of valid JSON
✓ consume buffers of valid JSON separated by two newlines
✓ provides each JSON object as soon as it is parsed
stream errors
✓ stops when any document contains invalid json
{ gzip: true }
✓ returns an array of streams
✓ parses blank files
streams
✓ consumes gzipped buffers of valid JSON
✓ parses valid gzipped JSON strings separated by two newlines
stream errors
✓ stops when the input is not valid gzip archive
defaults
✓ does not try to gunzip the content
opensearchArchiver: createGenerateDocRecordsStream()
✓ scolls 1000 documents at a time
✓ uses a 1 minute scroll timeout
✓ consumes index names and scrolls completely before continuing
opensearchArchiver: createIndexDocRecordsStream()
✓ consumes doc records and sends to `_bulk` api
✓ consumes multiple doc records and sends to `_bulk` api together
✓ waits until request is complete before sending more
✓ sends a maximum of 300 documents at a time
✓ emits an error if any request fails
opensearchArchiver: createCreateIndexStream()
defaults
✓ deletes existing indices, creates all
✓ deletes existing aliases, creates all
✓ passes through "hit" records
✓ creates aliases
✓ passes through records with unknown types
✓ passes through non-record values
skipExisting = true
✓ ignores preexisting indexes
✓ filters documents for skipped indices
opensearchArchiver: createDeleteIndexStream()
✓ deletes the index without checking if it exists
✓ reports the delete when the index existed
opensearchArchiver: createGenerateIndexRecordsStream()
✓ consumes index names and queries for the mapping of each
✓ filters index metadata from settings
✓ produces one index record for each index name it receives
✓ understands aliases
opensearchArchiver: createFilterRecordsStream()
✓ consumes any value
✓ produces record values that have a matching type
basic config file with a single app and test
✓ runs and prints expected output
failure hooks
✓ runs and prints expected output
readConfigFile()
✓ reads config from a file, returns an instance of Config class
✓ merges setting overrides into log
✓ supports loading config files from within config files
✓ throws if settings are invalid
408 passing (6s)
Done in 8.62s.
There are few mocha tests which needs to be migrated to Jest.
Following test cases should be converted to jest.
Steps to convert :
__tests__directory and append it withtest.js/test.tsextension.