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.