├── docs ├── static │ ├── .nojekyll │ └── img │ │ ├── aligned.svg │ │ ├── deviation.svg │ │ ├── apichange.svg │ │ └── roblox-only.svg ├── babel.config.js ├── .gitignore ├── sidebars.js ├── src │ └── css │ │ └── custom.css ├── README.md └── package.json ├── src ├── jest-runtime │ ├── src │ │ ├── __tests__ │ │ │ ├── requireZero.roblox.lua │ │ │ ├── test_root │ │ │ │ ├── init.lua │ │ │ │ ├── ManuallyMocked.lua │ │ │ │ ├── RegularModule.lua │ │ │ │ └── root.lua │ │ │ ├── requireNil.roblox.lua │ │ │ ├── requireOne.roblox.lua │ │ │ ├── requireTwo.roblox.lua │ │ │ ├── runtimeTestFile.lua │ │ │ ├── returnRequire.roblox.lua │ │ │ ├── mock_me.lua │ │ │ └── test_fenv │ │ │ │ └── init.lua │ │ ├── types.lua │ │ └── _types.lua │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ └── rotriever.toml ├── jest-config │ ├── src │ │ ├── __tests__ │ │ │ ├── mock_CustomReporter.lua │ │ │ ├── Defaults.spec.lua │ │ │ └── validatePattern.spec.lua │ │ ├── validatePattern.lua │ │ └── color.lua │ ├── .robloxrc │ ├── default.project.json │ └── rotriever.toml ├── jest-core │ ├── src │ │ ├── __tests__ │ │ │ ├── mock_CustomReporter.lua │ │ │ ├── test_root │ │ │ │ ├── module.jsx.lua │ │ │ │ ├── noTests.js.lua │ │ │ │ ├── module.foobar.lua │ │ │ │ ├── __testtests__ │ │ │ │ │ ├── test.js.lua │ │ │ │ │ ├── test.jsx.lua │ │ │ │ │ ├── test.foobar.lua │ │ │ │ │ ├── do-not-match-me.foo.lua │ │ │ │ │ └── not-really-a-test.foo.lua │ │ │ │ └── .hiddenFolder │ │ │ │ │ └── not-really-a-test.foo.lua │ │ │ └── test_root_with_(parentheses) │ │ │ │ ├── module.jsx.lua │ │ │ │ └── __testtests__ │ │ │ │ └── test.js.lua │ │ ├── pluralize.lua │ │ ├── getNoTestFoundPassWithNoTests.lua │ │ ├── init.lua │ │ ├── getProjectDisplayName.lua │ │ └── lib │ │ │ ├── createContext.lua │ │ │ └── logDebugMessages.lua │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ └── rotriever.toml ├── jest-jasmine2 │ ├── src │ │ └── init.lua │ ├── default.project.json │ ├── rotriever.toml │ └── README.md ├── pretty-format │ ├── src │ │ ├── __tests__ │ │ │ ├── dont_touch_im_used_in_snapshots │ │ │ │ ├── array.lua │ │ │ │ ├── format.lua │ │ │ │ ├── template.lua │ │ │ │ ├── interpolation.lua │ │ │ │ └── please_dont_touch_this.lua │ │ │ └── __snapshots__ │ │ │ │ └── react.spec.snap.lua │ │ └── plugins │ │ │ └── lib │ │ │ └── escapeHTML.lua │ ├── .robloxrc │ ├── default.project.json │ ├── rotriever.toml │ └── README.md ├── jest-circus │ ├── src │ │ ├── circus │ │ │ ├── legacy-code-todo-rewrite │ │ │ │ └── temporarySnapshotData.lua │ │ │ ├── eventHandler.lua │ │ │ ├── globalErrorHandlers.lua │ │ │ ├── state.lua │ │ │ ├── state_.lua │ │ │ ├── __tests__ │ │ │ │ ├── eventHandler.spec.lua │ │ │ │ └── circusItOnlyFailingTest.roblox.spec.lua │ │ │ ├── testCaseReportHandler.lua │ │ │ └── types.lua │ │ ├── runner.lua │ │ └── init.lua │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ └── rotriever.toml ├── .robloxrc ├── jest-runner │ ├── src │ │ └── testWorker.lua │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ └── rotriever.toml ├── path │ ├── default.project.json │ ├── README.md │ ├── src │ │ └── init.lua │ └── rotriever.toml ├── jest │ ├── default.project.json │ ├── README.md │ ├── src │ │ ├── args.roblox.lua │ │ ├── init.lua │ │ └── __tests__ │ │ │ └── roblox.spec.lua │ └── rotriever.toml ├── emittery │ ├── default.project.json │ ├── README.md │ └── rotriever.toml ├── expect │ ├── default.project.json │ ├── src │ │ ├── __tests__ │ │ │ └── __snapshots__ │ │ │ │ ├── assertionCounts.test.snap.lua │ │ │ │ └── roblox.spec.snap.lua │ │ └── jestMatchersObject_extracted.lua │ └── rotriever.toml ├── jest-console │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── rotriever.toml │ └── src │ │ └── types.lua ├── jest-diff │ ├── .robloxrc │ ├── default.project.json │ ├── src │ │ ├── Constants.lua │ │ ├── PrettyFormat.lua │ │ └── __tests__ │ │ │ └── DiffStringsRaw.spec.lua │ ├── rotriever.toml │ └── README.md ├── jest-each │ ├── .robloxrc │ ├── default.project.json │ ├── src │ │ ├── __tests__ │ │ │ └── __snapshots__ │ │ │ │ └── init.roblox.spec.snap.lua │ │ └── nilPlaceholder.lua │ ├── rotriever.toml │ └── README.md ├── jest-reporters │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── src │ │ └── __tests__ │ │ │ └── __snapshots__ │ │ │ ├── GitHubActionsReporter.spec.snap.lua │ │ │ └── getSnapshotStatus.spec.snap.lua │ └── rotriever.toml ├── jest-util │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── src │ │ ├── tryRealpath.lua │ │ ├── interopRequireDefault.lua │ │ ├── requireOrImportModule.lua │ │ ├── setGlobal.lua │ │ ├── pluralize.lua │ │ ├── isInteractive.lua │ │ ├── clearLine.lua │ │ ├── isPromise.lua │ │ ├── specialChars.lua │ │ ├── replacePathSepForGlob.lua │ │ ├── testPathPatternToRegExp.lua │ │ ├── preRunMessage.lua │ │ ├── __tests__ │ │ │ ├── tryRealpath.roblox.spec.lua │ │ │ ├── requireOrImportModule.roblox.spec.lua │ │ │ ├── interopRequireDefault.roblox.spec.lua │ │ │ ├── replacePathSepForGlob.roblox.spec.lua │ │ │ ├── testPathPatternToRegExp.roblox.spec.lua │ │ │ ├── isPromise.spec.lua │ │ │ ├── pluralize.roblox.spec.lua │ │ │ ├── errorWithStack.spec.lua │ │ │ └── clearLine.roblox.spec.lua │ │ ├── getFileSystemService.lua │ │ ├── formatTime.lua │ │ └── ErrorWithStack.lua │ └── rotriever.toml ├── throat │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ └── rotriever.toml ├── jest-benchmark │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── src │ │ ├── __tests__ │ │ │ └── utils.lua │ │ ├── heartbeatModule.lua │ │ ├── testModule.lua │ │ ├── init.lua │ │ ├── reporters │ │ │ └── FpsReporter.lua │ │ ├── MetricLogger.lua │ │ └── CustomReporters.lua │ └── rotriever.toml ├── jest-message-util │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── src │ │ └── __tests__ │ │ │ └── __snapshots__ │ │ │ ├── messages.spec.snap.lua │ │ │ └── messages.roblox.spec.snap.lua │ └── rotriever.toml ├── jest-mock │ ├── default.project.json │ ├── src │ │ └── __tests__ │ │ │ └── __snapshots__ │ │ │ └── roblox.spec.snap.lua │ ├── rotriever.toml │ └── README.md ├── jest-snapshot │ ├── .robloxrc │ ├── default.project.json │ ├── src │ │ ├── colors.lua │ │ ├── __tests__ │ │ │ ├── __snapshots__ │ │ │ │ └── snapshot.roblox.spec.snap.lua │ │ │ └── missingSnapshotFile.roblox.spec.lua │ │ ├── types.lua │ │ ├── plugins.lua │ │ └── PrettyFormat.lua │ └── rotriever.toml ├── jest-test-result │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── rotriever.toml │ └── src │ │ └── __tests__ │ │ └── formatTestResults.spec.lua ├── jest-types │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── rotriever.toml │ └── src │ │ ├── Transform.lua │ │ └── TestResult.lua ├── jest-validate │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── rotriever.toml │ └── src │ │ └── init.lua ├── test-utils │ ├── default.project.json │ ├── README.md │ ├── rotriever.toml │ └── src │ │ └── init.lua ├── jest-environment │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ └── rotriever.toml ├── jest-get-type │ ├── default.project.json │ ├── rotriever.toml │ └── README.md ├── jest-globals │ ├── default.project.json │ ├── README.md │ ├── src │ │ ├── init.lua │ │ ├── __tests__ │ │ │ └── index.lua │ │ └── index.lua │ └── rotriever.toml ├── jest-mock-genv │ ├── default.project.json │ └── rotriever.toml ├── jest-mock-rbx │ ├── default.project.json │ ├── rotriever.toml │ ├── src │ │ └── init.lua │ └── README.md ├── roblox-shared │ ├── default.project.json │ ├── README.md │ ├── src │ │ ├── escapePatternCharacters.lua │ │ ├── getDataModelService.lua │ │ ├── cleanLoadStringStack.lua │ │ ├── getParent.lua │ │ ├── __tests__ │ │ │ ├── __snapshots__ │ │ │ │ └── redactStackTrace.spec.snap.lua │ │ │ ├── cleanLoadStringStack.spec.lua │ │ │ └── Writeable.spec.lua │ │ ├── stripAnsi.lua │ │ ├── getRelativePath.lua │ │ ├── ensureDirectoryExists.lua │ │ ├── pruneDeps.lua │ │ ├── Writeable.lua │ │ └── redactStackTrace.lua │ └── rotriever.toml ├── diff-sequences │ ├── default.project.json │ ├── rotriever.toml │ ├── README.md │ └── src │ │ └── __tests__ │ │ └── __snapshots__ │ │ └── index.spec.snap.lua ├── jest-environment-luau │ ├── .robloxrc │ ├── README.md │ ├── default.project.json │ └── rotriever.toml ├── jest-fake-timers │ ├── default.project.json │ ├── rotriever.toml │ └── README.md ├── jest-matcher-utils │ ├── default.project.json │ ├── rotriever.toml │ ├── README.md │ └── src │ │ ├── deepCyclicCopyReplaceable.lua │ │ └── Replaceable.lua └── jest-snapshot-serializer-raw │ ├── .robloxrc │ ├── default.project.json │ ├── README.md │ ├── rotriever.toml │ └── src │ ├── always.lua │ └── init.lua ├── scripts ├── .luaurc ├── analyze.luau └── utils │ ├── run.luau │ └── patchErrorPolyfill.luau ├── Packages └── .robloxrc ├── .editorconfig ├── default.project.json ├── TestRoot ├── jest.config.lua ├── testSetupFile.lua └── normalizeStackTraces.lua ├── ocale.project.json ├── foreman.toml ├── selene.toml ├── .gitignore ├── rotriever.toml ├── .github └── pull_request_template.md └── LICENSE /docs/static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/requireZero.roblox.lua: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/test_root/init.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-config/src/__tests__/mock_CustomReporter.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/mock_CustomReporter.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/module.jsx.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/noTests.js.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/requireNil.roblox.lua: -------------------------------------------------------------------------------- 1 | return nil 2 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/requireOne.roblox.lua: -------------------------------------------------------------------------------- 1 | return 1 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/module.foobar.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/requireTwo.roblox.lua: -------------------------------------------------------------------------------- 1 | return nil, nil 2 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/test_root/ManuallyMocked.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/test_root/RegularModule.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/__testtests__/test.js.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/__testtests__/test.jsx.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/__testtests__/test.foobar.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-jasmine2/src/init.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX NOTE: no upstream 2 | 3 | return {} 4 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/.hiddenFolder/not-really-a-test.foo.lua: -------------------------------------------------------------------------------- 1 | return {} -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root_with_(parentheses)/module.jsx.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/pretty-format/src/__tests__/dont_touch_im_used_in_snapshots/array.lua: -------------------------------------------------------------------------------- 1 | return nil 2 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/legacy-code-todo-rewrite/temporarySnapshotData.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/__testtests__/do-not-match-me.foo.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root/__testtests__/not-really-a-test.foo.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/pretty-format/src/__tests__/dont_touch_im_used_in_snapshots/format.lua: -------------------------------------------------------------------------------- 1 | return nil 2 | -------------------------------------------------------------------------------- /src/pretty-format/src/__tests__/dont_touch_im_used_in_snapshots/template.lua: -------------------------------------------------------------------------------- 1 | return nil 2 | -------------------------------------------------------------------------------- /scripts/.luaurc: -------------------------------------------------------------------------------- 1 | { 2 | "aliases": { 3 | "lute": "~/.lute/typedefs/0.1.0/" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/jest-core/src/__tests__/test_root_with_(parentheses)/__testtests__/test.js.lua: -------------------------------------------------------------------------------- 1 | return {} 2 | -------------------------------------------------------------------------------- /src/pretty-format/src/__tests__/dont_touch_im_used_in_snapshots/interpolation.lua: -------------------------------------------------------------------------------- 1 | return nil 2 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/runtimeTestFile.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX NOTE: no upstream 2 | 3 | return {} 4 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/returnRequire.roblox.lua: -------------------------------------------------------------------------------- 1 | return function() 2 | return require 3 | end 4 | -------------------------------------------------------------------------------- /src/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } -------------------------------------------------------------------------------- /src/jest-runner/src/testWorker.lua: -------------------------------------------------------------------------------- 1 | local function worker() end 2 | 3 | return { 4 | worker = worker, 5 | } 6 | -------------------------------------------------------------------------------- /src/path/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Path", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /docs/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /src/jest-core/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } -------------------------------------------------------------------------------- /src/jest/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Jest", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Packages/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "nocheck" 4 | }, 5 | "lint": { 6 | "*": "disabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/emittery/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Emittery", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/expect/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Expect", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-console/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } -------------------------------------------------------------------------------- /src/jest-core/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestCore", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-diff/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-each/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-reporters/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } -------------------------------------------------------------------------------- /src/jest-runner/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } -------------------------------------------------------------------------------- /src/jest-runner/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestRunner", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-runtime/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } -------------------------------------------------------------------------------- /src/jest-util/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/throat/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/throat/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Throat", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-benchmark/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-circus/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-circus/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestCircus", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-config/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-config/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestConfig", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-diff/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestDiff", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-each/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestEach", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-message-util/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } -------------------------------------------------------------------------------- /src/jest-mock/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestMock", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-runtime/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestRuntime", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-snapshot/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-test-result/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } -------------------------------------------------------------------------------- /src/jest-types/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-types/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestTypes", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-util/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestUtil", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-validate/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/path/README.md: -------------------------------------------------------------------------------- 1 | # path 2 | 3 | This module is a modified version of: https://github.com/luvit/luvit/blob/master/deps/path/base.lua -------------------------------------------------------------------------------- /src/pretty-format/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test-utils/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TestUtils", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-console/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestConsole", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-environment/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-get-type/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestGetType", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-globals/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestGlobals", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-jasmine2/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestJasmine2", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-mock-genv/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestMockGenv", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-mock-rbx/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestMockRbx", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-reporters/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestReporters", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-snapshot/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestSnapshot", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-test-result/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestTestResult", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-validate/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestValidate", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/pretty-format/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "PrettyFormat", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/roblox-shared/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RobloxShared", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/diff-sequences/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "DiffSequences", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-benchmark/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestBenchmark", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-environment-luau/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/jest-environment-luau/README.md: -------------------------------------------------------------------------------- 1 | # jest-environment-luau 2 | 3 | *No upstream. Roblox only.* 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-environment/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestEnvironment", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-fake-timers/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestFakeTimers", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-matcher-utils/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestMatcherUtils", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-message-util/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestMessageUtil", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } -------------------------------------------------------------------------------- /src/jest-snapshot-serializer-raw/.robloxrc: -------------------------------------------------------------------------------- 1 | { 2 | "language": { 3 | "mode": "strict" 4 | }, 5 | "lint": { 6 | "*": "enabled" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/throat/README.md: -------------------------------------------------------------------------------- 1 | # throat 2 | 3 | Upstream: https://github.com/ForbesLindesay/throat/tree/6.0.1 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/emittery/README.md: -------------------------------------------------------------------------------- 1 | # emittery 2 | 3 | Upstream: https://github.com/sindresorhus/emittery/tree/v0.11.0 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-environment-luau/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestEnvironmentLuau", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-core/README.md: -------------------------------------------------------------------------------- 1 | # jest-core 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-core 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-snapshot-serializer-raw/default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestSnapshotSerializerRaw", 3 | "tree": { 4 | "$path": "src" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/jest-types/README.md: -------------------------------------------------------------------------------- 1 | # jest-types 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-types 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-util/README.md: -------------------------------------------------------------------------------- 1 | # jest-util 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-util 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/test-utils/README.md: -------------------------------------------------------------------------------- 1 | # test-utils 2 | 3 | Upstream: https://github.com/jestjs/jest/tree/v28.0.0/packages/test-utils 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-circus/README.md: -------------------------------------------------------------------------------- 1 | # jest-circus 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-circus 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.lua] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = false -------------------------------------------------------------------------------- /src/jest-runner/README.md: -------------------------------------------------------------------------------- 1 | # jest-reporters 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-runner 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-runtime/README.md: -------------------------------------------------------------------------------- 1 | # jest-runtime 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-runtime 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/mock_me.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX NOTE: no upstream 2 | local exports = {} 3 | exports.mocked = false 4 | exports.actual = true 5 | 6 | return exports 7 | -------------------------------------------------------------------------------- /src/jest-console/README.md: -------------------------------------------------------------------------------- 1 | # jest-console 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-console 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-reporters/README.md: -------------------------------------------------------------------------------- 1 | # jest-reporters 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-reporters 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-validate/README.md: -------------------------------------------------------------------------------- 1 | # jest-validate 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-validate 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | 9 | -------------------------------------------------------------------------------- /default.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestRoblox", 3 | "tree": { 4 | "$path": "Packages", 5 | "_Workspace": { 6 | "$path": "TestRoot" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/jest-environment/README.md: -------------------------------------------------------------------------------- 1 | # jest-environment 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-environment 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-test-result/README.md: -------------------------------------------------------------------------------- 1 | # jest-test-result 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-test-result 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-message-util/README.md: -------------------------------------------------------------------------------- 1 | # jest-message-util 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-message-util 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-snapshot-serializer-raw/README.md: -------------------------------------------------------------------------------- 1 | # jest-util 2 | 3 | Upstream: https://github.com/ikatyang/jest-snapshot-serializer-raw/tree/v1.2.0 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | 9 | -------------------------------------------------------------------------------- /src/roblox-shared/README.md: -------------------------------------------------------------------------------- 1 | # roblox-shared 2 | 3 | This module primarily contains shared util code moved out from the internals of other Jest modules to avoid cycles. 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | -------------------------------------------------------------------------------- /src/jest-util/src/tryRealpath.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/tryRealpath.ts 2 | -- ROBLOX deviation: not ported as it doesn't seem necessary in Lua 3 | return {} 4 | -------------------------------------------------------------------------------- /src/jest-util/src/interopRequireDefault.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/interopRequireDefault.ts 2 | -- ROBLOX deviation not ported as it doesn't seem necessary in Lua 3 | return {} 4 | -------------------------------------------------------------------------------- /src/jest-util/src/requireOrImportModule.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/requireOrImportModule.ts 2 | -- ROBLOX deviation not ported as it doesn't seem necessary in Lua 3 | return {} 4 | -------------------------------------------------------------------------------- /src/roblox-shared/src/escapePatternCharacters.lua: -------------------------------------------------------------------------------- 1 | local function escapePatternCharacters(str: string): string 2 | return string.gsub(str, "([%(%)%.%%%+%-%*%?%[%^%$])", "%%%1") 3 | end 4 | 5 | return { 6 | escapePatternCharacters = escapePatternCharacters, 7 | } 8 | -------------------------------------------------------------------------------- /TestRoot/jest.config.lua: -------------------------------------------------------------------------------- 1 | local Workspace = script.Parent 2 | 3 | return { 4 | setupFilesAfterEnv = { Workspace.testSetupFile }, 5 | testMatch = { "**/*.(spec|test)?(.lua|.luau)", "**/__tests__/index" }, 6 | snapshotSerializers = { Workspace.normalizeStackTraces } 7 | } 8 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/test_fenv/init.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX NOTE: no upstream 2 | 3 | local Packages = script.Parent.Parent.Parent 4 | local JestGlobals = require(Packages.Dev.JestGlobals) 5 | local jest = JestGlobals.jest 6 | 7 | return { 8 | game = game, 9 | workspace = workspace, 10 | jest = jest, 11 | } 12 | -------------------------------------------------------------------------------- /src/jest-benchmark/README.md: -------------------------------------------------------------------------------- 1 | # jest-benchmark 2 | 3 | *No upstream. Roblox only.* 4 | 5 | This package exports a collection of Luau utilities that can be used alongside Jest to provide structure for writing benchmarks. You can find its documentation in the [Jest documentation](https://roblox.github.io/jest-roblox-internal/jest-benchmark). 6 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /src/jest-globals/README.md: -------------------------------------------------------------------------------- 1 | # jest-globals 2 | 3 | Upstream: https://github.com/jestjs/jest/tree/v27.4.7/packages/jest-globals 4 | 5 | This package exports all the "global" methods used by Jest. You can find its documentation in the [Jest documentation](https://roblox.github.io/jest-roblox-internal). 6 | 7 | --- 8 | 9 | ### :pencil2: Notes 10 | -------------------------------------------------------------------------------- /scripts/analyze.luau: -------------------------------------------------------------------------------- 1 | local run = require("./utils/run") 2 | 3 | print("Running static analysis...") 4 | 5 | local seleneCmd = { "selene", "src" } 6 | local styluaCmd = { "stylua", "-c", "src" } 7 | local analyzeCmd = { "robloxdev-cli", "analyze", "default.project.json", "--fastFlags.allOnLuau" } 8 | 9 | run(seleneCmd) 10 | run(styluaCmd) 11 | run(analyzeCmd) 12 | -------------------------------------------------------------------------------- /src/path/src/init.lua: -------------------------------------------------------------------------------- 1 | local CurrentModule = script 2 | 3 | local pathModule = require(CurrentModule.path) 4 | local Path = pathModule.Path 5 | export type Path = pathModule.Path 6 | 7 | function makePathImpl() 8 | local path = Path.new() 9 | path:initialize("/", "/") 10 | return path 11 | end 12 | 13 | return { 14 | path = makePathImpl(), 15 | Path = Path, 16 | } 17 | -------------------------------------------------------------------------------- /src/jest-mock/src/__tests__/__snapshots__/roblox.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- Jest Roblox Snapshot v1, http://roblox.github.io/jest-roblox-internal/snapshot-testing 2 | local exports = {} 3 | exports[ [=[spyOn supported types does not allow tables with locked callable metatables 1]=] ] = [=[ 4 | "Cannot spy the foo property because it cannot be cloned. (protected metatable)"]=] 5 | 6 | return exports 7 | -------------------------------------------------------------------------------- /src/jest/README.md: -------------------------------------------------------------------------------- 1 | # jest 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest 4 | 5 | This package exports the `Jest` object used in Jest. The main entrypoint to the test framework should be `JestGlobals`. You can find its documentation in the [Jest documentation](https://roblox.github.io/jest-roblox-internal). 6 | 7 | --- 8 | 9 | ### :pencil2: Notes 10 | -------------------------------------------------------------------------------- /src/roblox-shared/src/getDataModelService.lua: -------------------------------------------------------------------------------- 1 | -- checks that the service exists and is accessible before returning it, otherwise returns nil 2 | return function(service: string) 3 | local success, result = pcall(function() 4 | local service = game:GetService(service) 5 | local _ = service.Name 6 | return service 7 | end) 8 | 9 | return success and result or nil 10 | end 11 | -------------------------------------------------------------------------------- /src/jest/src/args.roblox.lua: -------------------------------------------------------------------------------- 1 | local processServiceExists, ProcessService = pcall(function() 2 | return game:GetService("ProcessService") 3 | end) 4 | 5 | local args = {} 6 | 7 | if processServiceExists then 8 | for _, arg in ProcessService:GetCommandLineArgs() do 9 | local a = arg:split("=") 10 | a[1] = a[1]:gsub("^%-%-", "") 11 | args[a[1]] = a[2] or true 12 | end 13 | end 14 | 15 | return args 16 | -------------------------------------------------------------------------------- /ocale.project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JestRoblox", 3 | "tree": { 4 | "$className": "DataModel", 5 | "ReplicatedStorage": { 6 | "Packages": { 7 | "$path": "Packages", 8 | "TestRoot": { 9 | "$path": "TestRoot" 10 | } 11 | } 12 | }, 13 | "ServerScriptService": { 14 | "$properties": { 15 | "LoadStringEnabled": true 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/jest-benchmark/src/__tests__/utils.lua: -------------------------------------------------------------------------------- 1 | local exports = {} 2 | 3 | local function sum(nums: { number }) 4 | local sum = 0 5 | for _, num in nums do 6 | sum += num 7 | end 8 | return sum 9 | end 10 | exports.sum = sum 11 | 12 | local function average(nums: { number }) 13 | if #nums > 0 then 14 | return sum(nums) / #nums 15 | end 16 | return 0 17 | end 18 | exports.average = average 19 | 20 | return exports 21 | -------------------------------------------------------------------------------- /foreman.toml: -------------------------------------------------------------------------------- 1 | [tools] 2 | rotrieve = { source = "roblox/rotriever", version = "=0.5.21" } 3 | selene = { source = "Roblox/Kampfkarren-selene", version = "=0.25.0" } 4 | stylua = { source = "Roblox/JohnnyMorganz-StyLua", version = "=0.18.1" } 5 | rbx-aged-cli = { source = "roblox/rbx-aged-tool", version = "=5.8.1" } 6 | rojo = { source = "Roblox/rojo-rbx-rojo", version = "=7.3.0" } 7 | lute = { source = "luau-lang/lute", version = "0.1.0-nightly.20251018" } 8 | -------------------------------------------------------------------------------- /src/jest-each/src/__tests__/__snapshots__/init.roblox.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-each/src/__tests__/__snapshots__/index.test.ts.snap 2 | -- Jest Snapshot v1, https://goo.gl/fbAQLP 3 | local snapshots = {} 4 | 5 | snapshots["throws an error when not called with the right number of arguments 1"] = 6 | [=["`.each` must only be called with an Array or Tagged Template Literal."]=] 7 | 8 | return snapshots 9 | -------------------------------------------------------------------------------- /docs/static/img/aligned.svg: -------------------------------------------------------------------------------- 1 | AlignedAligned -------------------------------------------------------------------------------- /src/pretty-format/src/__tests__/dont_touch_im_used_in_snapshots/please_dont_touch_this.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | I copied this folder into here for testing purposes. 3 | 4 | Specifically, one of the unit tests tries to serialise this folder, and 5 | saves the result to a snapshot. If the snapshot changes, the test fails. 6 | 7 | So if you touch this folder, you'll break that test. 8 | 9 | Apart from that, nothing in here does anything meaningful. 10 | ]] 11 | 12 | return nil 13 | -------------------------------------------------------------------------------- /src/roblox-shared/src/cleanLoadStringStack.lua: -------------------------------------------------------------------------------- 1 | return function(line: string): string 2 | local spacing, filePath, lineNumber, extra = line:match('(%s*)%[string "(.-)"%]:(%d+)(.*)') 3 | if filePath then 4 | local match = filePath 5 | if spacing then 6 | match = spacing .. match 7 | end 8 | if lineNumber then 9 | match = match .. ":" .. lineNumber 10 | end 11 | if extra then 12 | match = match .. extra 13 | end 14 | return match 15 | end 16 | return line 17 | end 18 | -------------------------------------------------------------------------------- /docs/static/img/deviation.svg: -------------------------------------------------------------------------------- 1 | DeviationDeviation -------------------------------------------------------------------------------- /docs/static/img/apichange.svg: -------------------------------------------------------------------------------- 1 | API changeAPI change -------------------------------------------------------------------------------- /scripts/utils/run.luau: -------------------------------------------------------------------------------- 1 | local process = require("@lute/process") 2 | 3 | return function(cmd) 4 | print(`> {table.concat(cmd, " ")}`) 5 | 6 | local ok, result = pcall(function() 7 | return process.run(cmd, { stdio = "inherit", env = { PATH = `{process.cwd()}:{process.env.PATH}` } }) 8 | end) 9 | 10 | if not ok then 11 | error(result) 12 | end 13 | 14 | if result.ok then 15 | print(result.stdout) 16 | return result.stdout 17 | else 18 | error(`Error while running command: {result.stderr}`) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /src/jest-circus/src/runner.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-circus/runner.js 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | -- Allow people to use `jest-circus/runner` as a runner. 10 | local runner = require(script.Parent.circus["legacy-code-todo-rewrite"].jestAdapter) 11 | return runner 12 | -------------------------------------------------------------------------------- /scripts/utils/patchErrorPolyfill.luau: -------------------------------------------------------------------------------- 1 | local fs = require("@lute/fs") 2 | 3 | local OPTIMIZE_DIRECTIVE = "--!optimize 1" 4 | 5 | return function(path) 6 | local file = fs.open(path, "r+") 7 | if file == nil then 8 | error(`Failed to open file: {path}`) 9 | end 10 | 11 | local contents = string.split(fs.readfiletostring(path), "\n") 12 | 13 | if contents[1] ~= OPTIMIZE_DIRECTIVE then 14 | table.insert(contents, 1, OPTIMIZE_DIRECTIVE) 15 | fs.write(file, table.concat(contents, "\n")) 16 | end 17 | 18 | fs.close(file) 19 | end 20 | -------------------------------------------------------------------------------- /src/jest-types/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestTypes" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | RegExp = { workspace = true } 20 | -------------------------------------------------------------------------------- /src/jest-snapshot-serializer-raw/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestSnapshotSerializerRaw" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | 20 | [dev_dependencies] 21 | -------------------------------------------------------------------------------- /src/pretty-format/src/plugins/lib/escapeHTML.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/pretty-format/src/plugins/lib/escapeHTML.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local exports = {} 10 | local function escapeHTML(str: string): string 11 | return str:gsub("<", "<"):gsub(">", ">") 12 | end 13 | exports.default = escapeHTML 14 | return exports 15 | -------------------------------------------------------------------------------- /src/jest-types/src/Transform.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-types/src/Transform.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | -- this is here to make it possible to avoid huge dependency trees just for types 10 | export type TransformResult = { 11 | code: string, 12 | originalCode: string, 13 | sourceMapPath: string | nil, 14 | } 15 | return {} 16 | -------------------------------------------------------------------------------- /src/jest/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Jest" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | JestCore = { path = "../jest-core" } 19 | 20 | [dev_dependencies] 21 | JestGlobals = { path = "../jest-globals" } 22 | -------------------------------------------------------------------------------- /src/jest-util/src/setGlobal.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/setGlobal.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local exports = {} 11 | 12 | exports.default = function(globalToMutate: typeof(_G), key: string, value: unknown): () 13 | -- @ts-expect-error: no index 14 | globalToMutate[key] = value 15 | end 16 | 17 | return exports 18 | -------------------------------------------------------------------------------- /src/jest-validate/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestValidate" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | ChalkLua = { workspace = true } 20 | 21 | [dev_dependencies] 22 | -------------------------------------------------------------------------------- /src/path/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Path" 3 | authors = { workspace = true } 4 | description = "A set of path utilities." 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | 20 | [dev_dependencies] 21 | JestGlobals = { path = "../jest-globals" } 22 | -------------------------------------------------------------------------------- /src/jest-mock-genv/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestMockGenv" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | 20 | [dev_dependencies] 21 | JestGlobals = { path = "../jest-globals" } 22 | -------------------------------------------------------------------------------- /src/jest-util/src/pluralize.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/pluralize.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local exports = {} 11 | 12 | local function pluralize(word: string, count: number): string 13 | return ("%s %s%s"):format(tostring(count), word, if count == 1 then "" else "s") 14 | end 15 | exports.default = pluralize 16 | return exports 17 | -------------------------------------------------------------------------------- /src/roblox-shared/src/getParent.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX deviation: added to handle file paths in snapshot/State 2 | local function getParent(path: string, level_: number?): string 3 | local level = if level_ then level_ else 0 4 | 5 | local isUnixPath = string.sub(path, 1, 1) == "/" 6 | local t = {} 7 | 8 | for p in string.gmatch(path, "[^\\/][^\\/]*") do 9 | table.insert(t, p) 10 | end 11 | if level > 0 then 12 | t = { table.unpack(t, 1, #t - level) } 13 | end 14 | 15 | if isUnixPath then 16 | return "/" .. table.concat(t, "/") 17 | end 18 | 19 | return table.concat(t, "\\") 20 | end 21 | 22 | return getParent 23 | -------------------------------------------------------------------------------- /src/jest-core/src/pluralize.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-core/src/pluralize.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local exports = {} 10 | local function pluralize(word: string, count: number, ending: string): string 11 | return ("%s %s%s"):format(tostring(count), word, if count == 1 then "" else ending) 12 | end 13 | exports.default = pluralize 14 | return exports 15 | -------------------------------------------------------------------------------- /selene.toml: -------------------------------------------------------------------------------- 1 | std = "roblox" 2 | 3 | [config] 4 | empty_if = { comments_count = true } 5 | 6 | [rules] 7 | # remove this once the feature request here is implemented: https://github.com/Kampfkarren/selene/issues/181 8 | global_usage = "allow" 9 | # remove when the Luau type narrowing issues (and the workarounds) are resolved 10 | shadowing = "allow" 11 | # standard library functions are overridden for fake timers, also complains about internal services 12 | incorrect_standard_library_use = "allow" 13 | # prefer to align to upstream for readability 14 | multiple_statements = "allow" 15 | unused_variable = "allow" 16 | if_same_then_else = "allow" -------------------------------------------------------------------------------- /src/jest-snapshot-serializer-raw/src/always.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/ikatyang/jest-snapshot-serializer-raw/blob/v1.2.0/src/always.ts 2 | --[[ 3 | MIT License 4 | 5 | Copyright (c) Ika (https://github.com/ikatyang) 6 | ]] 7 | local exports = {} 8 | 9 | local function test( 10 | value: any 11 | ): boolean --[[ ROBLOX FIXME: change to TSTypePredicate equivalent if supported ]] --[[ value is string ]] 12 | return typeof(value) == "string" 13 | end 14 | exports.test = test 15 | 16 | local function print(value: string): string 17 | return value 18 | end 19 | exports.print = print 20 | 21 | return exports 22 | -------------------------------------------------------------------------------- /src/jest-util/src/isInteractive.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/isInteractive.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | --[[ 10 | ROBLOX deviation: no equivalent in Lua. Always returning false 11 | original code: 12 | import {isCI} from 'ci-info'; 13 | 14 | export default !!process.stdout.isTTY && process.env.TERM !== 'dumb' && !isCI; 15 | ]] 16 | return { 17 | default = false, 18 | } 19 | -------------------------------------------------------------------------------- /src/expect/src/__tests__/__snapshots__/assertionCounts.test.snap.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/expect/src/__tests__/__snapshots__/assertionCounts.test.ts.snap 2 | -- Jest Roblox Snapshot v1, http://roblox.github.io/jest-roblox-internal/snapshot-testing 3 | 4 | local exports = {} 5 | 6 | exports[ [=[.hasAssertions() throws if expected is not undefined 1]=] ] = [=[ 7 | 8 | expect(received)[.never].hasAssertions() 9 | 10 | Matcher error: this matcher must not have an expected argument 11 | 12 | Expected has type: number 13 | Expected has value: 2 14 | ]=] 15 | 16 | return exports 17 | -------------------------------------------------------------------------------- /src/jest-message-util/src/__tests__/__snapshots__/messages.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-message-util/src/__tests__/__snapshots__/messages.test.ts.snap 2 | -- Jest Snapshot v1, https://goo.gl/fbAQLP 3 | 4 | local exports = {} 5 | 6 | exports[".formatExecError() 1"] = [[ 7 | 8 | " ● Test suite failed to run 9 | 10 | Whoops! 11 | " 12 | ]] 13 | 14 | --[[ 15 | ROBLOX deviation: skipped lines 10-114 16 | original code: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-message-util/src/__tests__/__snapshots__/messages.test.ts.snap#L10-L114 17 | ]] 18 | 19 | return exports 20 | -------------------------------------------------------------------------------- /src/jest-test-result/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestTestResult" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | JestTypes = { path = "../jest-types" } 20 | 21 | [dev_dependencies] 22 | JestGlobals = { path = "../jest-globals" } 23 | -------------------------------------------------------------------------------- /src/jest-globals/src/init.lua: -------------------------------------------------------------------------------- 1 | -- /** 2 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 3 | -- * 4 | -- * This source code is licensed under the MIT license found in the 5 | -- * LICENSE file in the root directory of this source tree. 6 | -- * 7 | -- */ 8 | 9 | -- ROBLOX deviation START: add export for additional Expect types 10 | local Packages = script.Parent 11 | local ExpectModule = require(Packages.Expect) 12 | export type MatcherState = ExpectModule.MatcherState 13 | export type ExpectExtended = ExpectModule.ExpectExtended 14 | -- ROBLOX deviation END 15 | 16 | return require(script.index) 17 | -------------------------------------------------------------------------------- /src/jest-benchmark/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestBenchmark" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = "https://roblox.github.io/jest-roblox-internal/jest-benchmark" 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | JestGlobals = { path = "../jest-globals" } 19 | LuauPolyfill = { workspace = true } 20 | JestTypes = { path = "../jest-types" } 21 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/eventHandler.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-circus/src/eventHandler.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | -- ROBLOX deviation START: moved implementation to `combined.lua` to avoid cyclic dependencies 10 | local combinedModule = require(script.Parent.combined) 11 | local exports = {} 12 | 13 | exports.default = combinedModule.eventHandler 14 | -- ROBLOX deviation END 15 | 16 | return exports 17 | -------------------------------------------------------------------------------- /TestRoot/testSetupFile.lua: -------------------------------------------------------------------------------- 1 | --[[* 2 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | ]] 7 | -- Some of the `jest-runtime` tests are very slow and cause 8 | -- timeouts on travis 9 | -- jest.setTimeout(70000) 10 | type Function = (...any) -> ...any 11 | 12 | local JestGlobals = require(script.Parent.JestGlobals.JestGlobals) 13 | local jestExpect = JestGlobals.expect 14 | 15 | local ConvertAnsi = require(script.Parent.Parent.PrettyFormat).plugins.ConvertAnsi 16 | 17 | jestExpect.addSnapshotSerializer(ConvertAnsi) 18 | -------------------------------------------------------------------------------- /src/jest-mock-rbx/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestMockRbx" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | JestTypes = { path = "../jest-types" } 20 | 21 | [dev_dependencies] 22 | JestGlobals = { path = "../jest-globals" } 23 | JestConfig = { path = "../jest-config" } 24 | -------------------------------------------------------------------------------- /src/emittery/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Emittery" 3 | authors = { workspace = true } 4 | description = "Simple and modern async event emitter." 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = "https://github.com/sindresorhus/emittery/blob/v0.11.0/readme.md" 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | 21 | [dev_dependencies] 22 | JestGlobals = { path = "../jest-globals" } 23 | -------------------------------------------------------------------------------- /src/jest-get-type/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestGetType" 3 | authors = { workspace = true } 4 | description = "A utility function to get the type of a value, including Luau and Roblox types." 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | RegExp = { workspace = true } 20 | 21 | [dev_dependencies] 22 | JestGlobals = { path = "../jest-globals" } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Rotriever files 2 | rotriever.lock 3 | Packages/* 4 | !Packages/.robloxrc 5 | 6 | # Test places and build artifacts 7 | /*.rbxlx 8 | /*.rbxl 9 | /*.rbxmx 10 | /*.rbxm 11 | 12 | # LuaCov reports 13 | /luacov.* 14 | 15 | # MkDocs build output 16 | /site 17 | 18 | # Cargo build output 19 | /target 20 | 21 | # MacOS files 22 | **/.DS_Store 23 | 24 | # Docusaurus files 25 | /docs/.docusaurus 26 | /docs/build 27 | /docs/node_modules 28 | /docs/yarn.lock 29 | 30 | # Selene 31 | roblox.toml 32 | 33 | # Editor files 34 | .vscode/launch.json 35 | .idea 36 | .vscode 37 | 38 | # Artifacts from tooling 39 | jest_runner_tmp 40 | lcov.info 41 | rbx-aged-tool.log 42 | sourcemap.json 43 | **/__pycache__ 44 | -------------------------------------------------------------------------------- /src/diff-sequences/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "DiffSequences" 3 | authors = { workspace = true } 4 | description = "Compare items in two sequences to find a longest common subsequence." 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = "https://github.com/jestjs/jest/blob/v27.4.7/packages/diff-sequences/README.md" 8 | keywords = ["diff"] 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | 20 | [dev_dependencies] 21 | JestGlobals = { path = "../jest-globals" } 22 | -------------------------------------------------------------------------------- /src/jest-fake-timers/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestFakeTimers" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | JestGetType = { path = "../jest-get-type" } 20 | JestMock = { path = "../jest-mock" } 21 | 22 | [dev_dependencies] 23 | JestGlobals = { path = "../jest-globals" } 24 | -------------------------------------------------------------------------------- /src/throat/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Throat" 3 | authors = { workspace = true } 4 | description = "Throttle a collection of promise returning functions." 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = "https://github.com/ForbesLindesay/throat/blob/6.0.1/README.md" 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | 21 | [dev_dependencies] 22 | JestGlobals = { path = "../jest-globals" } 23 | -------------------------------------------------------------------------------- /src/jest-reporters/src/__tests__/__snapshots__/GitHubActionsReporter.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- Jest Roblox Snapshot v1, http://roblox.github.io/jest-roblox-internal/snapshot-testing 2 | local exports = {} 3 | exports[ [=[reporter extracts the correct filename and line 1]=] ] = [=[ 4 | "::error file=/Users/rng/jest-roblox/src/jest-reporters/src/__tests__/some.spec.lua,line=9::Error: expect(received).toEqual(expected) -- deep equality%0A %0A Expected: \"b\"%0A Received: \"a\"%0A _Workspace.JestReporters.JestReporters.__tests__.some.spec:9%0A _Workspace.JestCircus.JestCircus.circus.utils:369%0A _Index.Promise.Promise:172 function runExecutor%0A _Index.Promise.Promise:299"]=] 5 | 6 | return exports 7 | -------------------------------------------------------------------------------- /src/test-utils/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "TestUtils" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | PrettyFormat = { path = "../pretty-format" } 19 | ChalkLua = { workspace = true } 20 | JestTypes = { path = "../jest-types" } 21 | JestEnvironmentLuau = { path = "../jest-environment-luau" } 22 | LuauPolyfill = { workspace = true } 23 | -------------------------------------------------------------------------------- /src/jest-environment/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestEnvironment" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | JestFakeTimers = { path = "../jest-fake-timers" } 20 | JestMock = { path = "../jest-mock" } 21 | JestTypes = { path = "../jest-types" } 22 | JestMockGenv = { path = '../jest-mock-genv' } 23 | -------------------------------------------------------------------------------- /src/jest-diff/src/Constants.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-diff/src/constants.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- */ 8 | 9 | local NO_DIFF_MESSAGE = "Compared values have no visual difference." 10 | 11 | local SIMILAR_MESSAGE = "Compared values serialize to the same structure.\n" 12 | .. "Printing internal object structure without calling `toJSON` instead." 13 | 14 | return { 15 | NO_DIFF_MESSAGE = NO_DIFF_MESSAGE, 16 | SIMILAR_MESSAGE = SIMILAR_MESSAGE, 17 | } 18 | -------------------------------------------------------------------------------- /src/jest-jasmine2/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestJasmine2" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | 20 | [dev_dependencies] 21 | JestGlobals = { path = "../jest-globals" } 22 | Expect = { path = "../expect" } 23 | Promise = { workspace = true } 24 | RobloxShared = { path = "../roblox-shared" } 25 | -------------------------------------------------------------------------------- /src/jest-config/src/__tests__/Defaults.spec.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-config/src/__tests__/Defaults.test.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent.Parent.Parent 10 | local JestGlobals = require(Packages.Dev.JestGlobals) 11 | local expect = JestGlobals.expect 12 | local it = JestGlobals.it 13 | 14 | local defaults = require(script.Parent.Parent).defaults 15 | 16 | it("get configuration defaults", function() 17 | expect(defaults).toBeDefined() 18 | end) 19 | -------------------------------------------------------------------------------- /src/jest-globals/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestGlobals" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Expect = { path = "../expect" } 20 | JestEnvironment = { path = "../jest-environment" } 21 | JestTypes = { path = "../jest-types" } 22 | 23 | [dev_dependencies] 24 | JestGlobals = { path = "../jest-globals" } 25 | -------------------------------------------------------------------------------- /src/jest-core/src/getNoTestFoundPassWithNoTests.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-core/src/getNoTestFoundPassWithNoTests.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent.Parent 10 | 11 | local exports = {} 12 | 13 | local chalk = require(Packages.ChalkLua) 14 | 15 | local function getNoTestFoundPassWithNoTests(): string 16 | return chalk.bold("No tests found, exiting with code 0") 17 | end 18 | exports.default = getNoTestFoundPassWithNoTests 19 | 20 | return exports 21 | -------------------------------------------------------------------------------- /src/roblox-shared/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "RobloxShared" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | JestGetType = { path = "../jest-get-type" } 19 | LuauPolyfill = { workspace = true } 20 | JestMock = { path = "../jest-mock" } 21 | 22 | [dev_dependencies] 23 | JestGlobals = { path = "../jest-globals" } 24 | JestConfig = { path = "../jest-config" } 25 | -------------------------------------------------------------------------------- /src/jest-environment-luau/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestEnvironmentLuau" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | JestFakeTimers = { path = "../jest-fake-timers" } 21 | JestMock = { path = "../jest-mock" } 22 | JestTypes = { path = "../jest-types" } 23 | JestEnvironment = { path = "../jest-environment" } 24 | -------------------------------------------------------------------------------- /src/roblox-shared/src/__tests__/__snapshots__/redactStackTrace.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- Jest Roblox Snapshot v1, http://roblox.github.io/jest-roblox-internal/snapshot-testing 2 | local exports = {} 3 | exports[ [=[stack traces should stay the same in snapshots 1]=] ] = [=[ 4 | 5 | "Redacted.Stack.Trace:1337 function epicDuck 6 | Redacted.Stack.Trace:1337 function epicDuck 7 | Redacted.Stack.Trace:1337 function epicDuck 8 | Redacted.Stack.Trace:1337 function epicDuck" 9 | ]=] 10 | 11 | exports[ [=[stack traces should stay the same in snapshots 2]=] ] = [=[ 12 | 13 | "Redacted.Stack.Trace:1337 function epicDuck 14 | Redacted.Stack.Trace:1337 function epicDuck 15 | Redacted.Stack.Trace:1337 function epicDuck 16 | Redacted.Stack.Trace:1337 function epicDuck" 17 | ]=] 18 | 19 | return exports 20 | -------------------------------------------------------------------------------- /rotriever.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["src/*"] 3 | authors = ["Raymond Ng ", "Daniel Fox ", "#jest-roblox"] 4 | description = "A Luau testing framework based on Jest. See JestGlobals for the entry point." 5 | repository = "https://github.com/Roblox/jest-roblox-internal" 6 | homepage = "https://roblox.github.io/jest-roblox-internal" 7 | documentation = "https://roblox.github.io/jest-roblox-internal" 8 | keywords = ["jest", "unit_testing"] 9 | version = "3.13.3" 10 | license = "MIT" 11 | 12 | [config] 13 | registry_index = true 14 | 15 | [workspace.dependencies] 16 | ChalkLua = "0.3.0" 17 | LuauPolyfill = "1" 18 | RegExp = "0.2.2" 19 | Promise = "3.3.0" 20 | React = "17.0.1" 21 | ReactIs = "17.0.1" 22 | ReactTestRenderer = "17.0.1" 23 | Picomatch = "0.4.0" 24 | -------------------------------------------------------------------------------- /src/jest-mock/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestMock" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | JestMockGenv = { path = "../jest-mock-genv" } 20 | JestMockRbx = { path = "../jest-mock-rbx" } 21 | JestTypes = { path = "../jest-types" } 22 | 23 | [dev_dependencies] 24 | JestGlobals = { path = "../jest-globals" } 25 | JestConfig = { path = "../jest-config" } 26 | -------------------------------------------------------------------------------- /src/jest-runtime/src/types.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-runtime/src/types.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local Packages = script.Parent.Parent 11 | local typesModule = require(Packages.JestTypes) 12 | type Config_ProjectConfig = typesModule.Config_ProjectConfig 13 | 14 | export type Context = { 15 | config: Config_ProjectConfig, 16 | -- ROBLOX deviation START: no supported 17 | -- hasteFS: HasteFS, 18 | -- moduleMap: ModuleMap, 19 | -- resolver: Resolver, 20 | -- ROBLOX deviation END 21 | } 22 | 23 | return {} 24 | -------------------------------------------------------------------------------- /src/jest-core/src/init.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-core/src/jest.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local exports = {} 10 | 11 | exports.SearchSource = require(script.SearchSource).default 12 | exports.createTestScheduler = require(script.TestScheduler).createTestScheduler 13 | exports.TestWatcher = require(script.TestWatcher).default 14 | exports.runCLI = require(script.cli).runCLI 15 | -- ROBLOX deviation START: not needed 16 | -- exports.getVersion = require(script.version).default 17 | -- ROBLOX deviation END 18 | return exports 19 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/globalErrorHandlers.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-circus/src/globalErrorHandlers.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | -- ROBLOX deviation START: moved implementation to `combined.lua` to avoid cyclic dependencies 10 | 11 | local combinedModule = require(script.Parent.combined) 12 | local exports = {} 13 | 14 | exports.injectGlobalErrorHandlers = combinedModule.injectGlobalErrorHandlers 15 | exports.restoreGlobalErrorHandlers = combinedModule.restoreGlobalErrorHandlers 16 | 17 | -- ROBLOX deviation END 18 | 19 | return exports 20 | -------------------------------------------------------------------------------- /docs/sidebars.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | docs: [ 3 | { 4 | type: 'category', 5 | label: 'Introduction', 6 | items: [ 7 | 'getting-started', 8 | 'using-matchers', 9 | 'asynchronous', 10 | 'setup-teardown', 11 | 'mock-functions', 12 | 'test-filtering' 13 | ], 14 | }, 15 | { 16 | type: 'category', 17 | label: 'Guides', 18 | items: [ 19 | 'snapshot-testing', 20 | 'timer-mocks', 21 | 'global-mocks', 22 | 'testez-migration', 23 | 'upgrading-to-jest3', 24 | ] 25 | }, 26 | 'deviations', 27 | ], 28 | api: [ 29 | 'api', 30 | 'expect', 31 | 'mock-function-api', 32 | 'jest-object', 33 | 'jest-benchmark', 34 | 'configuration', 35 | 'cli', 36 | ] 37 | }; 38 | -------------------------------------------------------------------------------- /src/jest-snapshot/src/colors.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-snapshot/src/colors.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- */ 8 | 9 | -- ROBLOX deviation: tuples not currently supported in Luau so we use a number array instead 10 | export type RGB = { number } 11 | 12 | return { 13 | aForeground2 = 90, 14 | aBackground2 = 225, 15 | 16 | bForeground2 = 23, 17 | bBackground2 = 195, 18 | 19 | aForeground3 = { 0x80, 0, 0x80 }, 20 | aBackground3 = { 0xff, 0xd7, 0xff }, 21 | 22 | bForeground3 = { 0, 0x5f, 0x5f }, 23 | bBackground3 = { 0xd7, 0xff, 0xff }, 24 | } 25 | -------------------------------------------------------------------------------- /src/jest-util/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestUtil" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | ChalkLua = { workspace = true } 21 | RegExp = { workspace = true } 22 | Picomatch = { workspace = true } 23 | JestTypes = { path = "../jest-types" } 24 | RobloxShared = { path = "../roblox-shared" } 25 | 26 | [dev_dependencies] 27 | JestGlobals = { path = "../jest-globals" } 28 | -------------------------------------------------------------------------------- /src/jest-each/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestEach" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | ChalkLua = { workspace = true } 19 | LuauPolyfill = { workspace = true } 20 | RegExp = { workspace = true } 21 | JestGetType = { path = "../jest-get-type" } 22 | JestTypes = { path = "../jest-types" } 23 | JestUtil = { path = "../jest-util" } 24 | PrettyFormat = { path = "../pretty-format" } 25 | 26 | [dev_dependencies] 27 | JestGlobals = { path = "../jest-globals" } 28 | -------------------------------------------------------------------------------- /src/jest-benchmark/src/heartbeatModule.lua: -------------------------------------------------------------------------------- 1 | --!strict 2 | --[[ 3 | * Copyright (c) Roblox Corporation. All rights reserved. 4 | * Licensed under the MIT License (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://opensource.org/licenses/MIT 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ]] 16 | -- ROBLOX NOTE: no upstream 17 | 18 | -- Re-export RunService.Heartbeat so that it can be easily mocked in tests 19 | return game:GetService("RunService").Heartbeat 20 | -------------------------------------------------------------------------------- /src/roblox-shared/src/stripAnsi.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX upstream: no upstream 16 | local function stripAnsi(text: string) 17 | local res = string.gsub(text, "[\27\155][][()#;?%d]*[A-PRZcf-ntqry=><~]", "") 18 | return res 19 | end 20 | return stripAnsi 21 | -------------------------------------------------------------------------------- /docs/src/css/custom.css: -------------------------------------------------------------------------------- 1 | /* stylelint-disable docusaurus/copyright-header */ 2 | /** 3 | * Any CSS included here will be global. The classic template 4 | * bundles Infima by default. Infima is a CSS framework designed to 5 | * work well for content-centric websites. 6 | */ 7 | 8 | /* You can override the default Infima variables here. */ 9 | :root { 10 | --ifm-color-primary: #cc3333; 11 | --ifm-color-primary-dark: #b82e2e; 12 | --ifm-color-primary-darker: #ad2b2b; 13 | --ifm-color-primary-darkest: #8f2424; 14 | --ifm-color-primary-light: #d14747; 15 | --ifm-color-primary-lighter: #d45252; 16 | --ifm-color-primary-lightest: #db7070; 17 | --ifm-code-font-size: 95%; 18 | } 19 | 20 | .docusaurus-highlight-code-line { 21 | background-color: rgb(72, 77, 91); 22 | display: block; 23 | margin: 0 calc(-1 * var(--ifm-pre-padding)); 24 | padding: 0 var(--ifm-pre-padding); 25 | } 26 | -------------------------------------------------------------------------------- /src/jest-util/src/clearLine.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/clearLine.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local CurrentModule = script.Parent 11 | local Packages = CurrentModule.Parent 12 | local LuauPolyfill = require(Packages.LuauPolyfill) 13 | local Boolean = LuauPolyfill.Boolean 14 | local RobloxShared = require(Packages.RobloxShared) 15 | type Writeable = RobloxShared.Writeable 16 | local exports = {} 17 | 18 | local function clearLine(stream: Writeable): () 19 | if Boolean.toJSBoolean(stream.isTTY) then 20 | stream:write("\x1b[999D\x1b[K") 21 | end 22 | end 23 | exports.default = clearLine 24 | 25 | return exports 26 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Problem 2 | Describe the problem. Include the JIRA ticket ID and a short description of the ticket in the PR title: `JIRAPROJECT-ID | Short Description of Ticket` 3 | 4 | ## Solution 5 | Describe how the solution was derived. 6 | 7 | ## Testing 8 | Describe how the solution was tested (ideally unit tests). If done manually, describe the process and outcome. 9 | 10 | ## Checklist 11 | ### For all changes 12 | - [ ] Describe this change in `CHANGELOG.md` 13 | - [ ] [Open a PR to add/update relevant examples in jest-demo](https://github.com/Roblox/jest-demo) 14 | ### When working with upstream code (remove if not applicable) 15 | - [ ] Newly translated modules have a `README.md` file with notes about the translation 16 | - [ ] All deviations are notated in code with `-- ROBLOX deviation: comment` 17 | - [ ] Translated files include a comment with a link to the upstream file 18 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. 4 | 5 | ## Installation 6 | 7 | ```console 8 | yarn install 9 | ``` 10 | 11 | ## Local Development 12 | 13 | ```console 14 | yarn start 15 | ``` 16 | 17 | This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ## Build 20 | 21 | ```console 22 | yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ## Deployment 28 | 29 | ```console 30 | GIT_USER= GIT_PASS= yarn deploy 31 | ``` 32 | 33 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 34 | -------------------------------------------------------------------------------- /src/jest-each/src/nilPlaceholder.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX upstream: no upstream 16 | 17 | -- ROBLOX Comment: nil value placeholder 18 | local NIL = newproxy(true) 19 | local mt = getmetatable(NIL) 20 | mt.__tostring = function() 21 | return "nil" 22 | end 23 | 24 | return NIL 25 | -------------------------------------------------------------------------------- /src/jest-util/src/isPromise.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/isPromise.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local CurrentModule = script.Parent 11 | local Packages = CurrentModule.Parent 12 | local Promise = require(Packages.Promise) 13 | 14 | local exports = {} 15 | 16 | local function isPromise( 17 | candidate: unknown 18 | ): boolean --[[ ROBLOX FIXME: change to TSTypePredicate equivalent if supported ]] --[[ candidate is Promise ]] 19 | -- ROBLOX deviation: using Promise library implementation to check if a variable is a Promise 20 | return Promise.is(candidate) 21 | end 22 | exports.default = isPromise 23 | return exports 24 | -------------------------------------------------------------------------------- /src/jest-console/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestConsole" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | JestTypes = { path = "../jest-types" } 20 | ChalkLua = { workspace = true } 21 | JestUtil = { path = "../jest-util" } 22 | JestMessageUtil = { path = "../jest-message-util" } 23 | JestMock = { path = "../jest-mock" } 24 | JestEach = { path = "../jest-each" } 25 | RobloxShared = { path = "../roblox-shared" } 26 | 27 | [dev_dependencies] 28 | JestGlobals = { path = "../jest-globals" } 29 | -------------------------------------------------------------------------------- /src/jest-matcher-utils/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestMatcherUtils" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | JestDiff = { path = "../jest-diff" } 19 | JestGetType = { path = "../jest-get-type" } 20 | PrettyFormat = { path = "../pretty-format" } 21 | ChalkLua = { workspace = true } 22 | LuauPolyfill = { workspace = true } 23 | RegExp = { workspace = true } 24 | 25 | [dev_dependencies] 26 | RobloxShared = { path = "../roblox-shared" } 27 | JestGlobals = { path = "../jest-globals" } 28 | TestUtils = { path = "../test-utils" } 29 | -------------------------------------------------------------------------------- /docs/static/img/roblox-only.svg: -------------------------------------------------------------------------------- 1 | Roblox onlyRoblox only -------------------------------------------------------------------------------- /src/jest-message-util/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestMessageUtil" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | ChalkLua = { workspace = true } 20 | RegExp = { workspace = true } 21 | JestTypes = { path = "../jest-types"} 22 | PrettyFormat = { path = "../pretty-format"} 23 | RobloxShared = { path = "../roblox-shared"} 24 | 25 | [dev_dependencies] 26 | JestGlobals = { path = "../jest-globals" } 27 | JestSnapshotSerializerRaw = { path = "../jest-snapshot-serializer-raw" } 28 | Promise = { workspace = true } 29 | -------------------------------------------------------------------------------- /src/pretty-format/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "PrettyFormat" 3 | authors = { workspace = true } 4 | description = "Stringify any Luau value." 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = "https://github.com/jestjs/jest/blob/v27.4.7/packages/pretty-format/README.md" 8 | keywords = ["string", "serialize", "format"] 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | JestGetType = { path = "../jest-get-type" } 19 | ChalkLua = { workspace = true } 20 | LuauPolyfill = { workspace = true } 21 | RegExp = { workspace = true } 22 | ReactIs = { workspace = true } 23 | RobloxShared = { path = "../roblox-shared" } 24 | 25 | [dev_dependencies] 26 | React = { workspace = true } 27 | ReactTestRenderer = { workspace = true } 28 | JestGlobals = { path = "../jest-globals" } 29 | -------------------------------------------------------------------------------- /src/jest-snapshot/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestSnapshot" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | ChalkLua = { workspace = true } 19 | LuauPolyfill = { workspace = true } 20 | Promise = { workspace = true } 21 | JestTypes = { path = "../jest-types" } 22 | JestDiff = { path = "../jest-diff" } 23 | JestGetType = { path = "../jest-get-type" } 24 | JestMatcherUtils = { path = "../jest-matcher-utils" } 25 | PrettyFormat = { path = "../pretty-format" } 26 | RobloxShared = { path = "../roblox-shared" } 27 | 28 | [dev_dependencies] 29 | JestGlobals = { path = "../jest-globals" } 30 | -------------------------------------------------------------------------------- /src/jest-diff/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestDiff" 3 | authors = { workspace = true } 4 | description = "Display differences clearly so people can review changes confidently." 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = "https://github.com/jestjs/jest/blob/v27.4.7/packages/jest-diff/README.md" 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | DiffSequences = { path = "../diff-sequences" } 19 | JestGetType = { path = "../jest-get-type" } 20 | PrettyFormat = { path = "../pretty-format" } 21 | JestTypes = { path = "../jest-types" } 22 | ChalkLua = { workspace = true } 23 | LuauPolyfill = { workspace = true } 24 | 25 | [dev_dependencies] 26 | JestGlobals = { path = "../jest-globals" } 27 | TestUtils = { path = "../test-utils" } 28 | -------------------------------------------------------------------------------- /src/jest-snapshot/src/__tests__/__snapshots__/snapshot.roblox.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- Jest Roblox Snapshot v1, http://roblox.github.io/jest-roblox-internal/snapshot-testing 2 | local exports = {} 3 | exports[ [=[custom snapshot matchers: toMatchTrimmedSnapshot 1]=] ] = [=[ 4 | "extra long"]=] 5 | 6 | exports[ [=[native lua errors 1]=] ] = [=[ 7 | "_Workspace.JestSnapshot.JestSnapshot.__tests__.snapshot.roblox.spec:35: oops"]=] 8 | 9 | exports[ [=[test with newlines 10 | in the name 11 | and body 1]=] ] = [=[ 12 | 13 | "a 14 | b" 15 | ]=] 16 | 17 | exports[ [=[tests snapshots with asymmetric matchers 1]=] ] = [=[ 18 | 19 | Table { 20 | "createdAt": Any, 21 | "id": Any, 22 | "name": "LeBron James", 23 | } 24 | ]=] 25 | 26 | exports[ [=[tests snapshots with asymmetric matchers and a subset of properties 1]=] ] = [=[ 27 | 28 | Table { 29 | "createdAt": Any, 30 | "id": Any, 31 | "name": "LeBron James", 32 | } 33 | ]=] 34 | 35 | return exports 36 | -------------------------------------------------------------------------------- /src/jest-benchmark/src/testModule.lua: -------------------------------------------------------------------------------- 1 | --!strict 2 | --[[ 3 | * Copyright (c) Roblox Corporation. All rights reserved. 4 | * Licensed under the MIT License (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://opensource.org/licenses/MIT 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ]] 16 | -- ROBLOX NOTE: no upstream 17 | 18 | -- Re-export JestGlobals.test so that it can be easily mocked in tests 19 | local Packages = script:FindFirstAncestor("JestBenchmark").Parent 20 | local JestGlobals = require(Packages.JestGlobals) 21 | local test = JestGlobals.test 22 | 23 | return test 24 | -------------------------------------------------------------------------------- /src/jest-config/src/validatePattern.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-config/src/validatePattern.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent.Parent 10 | local LuauPolyfill = require(Packages.LuauPolyfill) 11 | local Boolean = LuauPolyfill.Boolean 12 | local RegExp = require(Packages.RegExp) 13 | 14 | local exports = {} 15 | 16 | local function validatePattern(pattern: string?): boolean 17 | if pattern ~= nil and Boolean.toJSBoolean(pattern) then 18 | local ok = pcall(function() 19 | -- eslint-disable-next-line no-new 20 | RegExp(pattern, "i") 21 | end) 22 | if not ok then 23 | return false 24 | end 25 | end 26 | return true 27 | end 28 | exports.default = validatePattern 29 | return exports 30 | -------------------------------------------------------------------------------- /src/diff-sequences/README.md: -------------------------------------------------------------------------------- 1 | # diff-sequences 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/diff-sequences 4 | 5 | Compare items in two sequences to find a longest common subsequence. 6 | 7 | --- 8 | 9 | ### :pencil2: Notes 10 | * :x: Property tests and performance tests from upstream are not included. 11 | * :warning: Lua does not allow indexing into strings, the consumer is expected to handle the input types in `isCommon` and `foundSubsequence`. 12 | * A `stringToArray` function is implemented to convert input strings to arrays for tests. 13 | * Substring tests are done using arrays of characters instead. The substring comparison methods are omitted. 14 | * Lua is 1 indexed so array indices are replaced with `index + 1`. 15 | * Uses of `NOT_YET_SET` are replaced with just a 0 since this is a JS-specific workaround. 16 | * Lua treats `0` as a true value so `nChange || baDeltaLength` needs to be written as `nChange ~= 0 and nChange or baDeltaLength`. 17 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/state.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-circus/src/state.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | -- ROBLOX deviation START: moved implementation to `combined.lua` to avoid cyclic dependencies 10 | 11 | local combinedModule = require(script.Parent.combined) 12 | 13 | local exports = {} 14 | 15 | exports.ROOT_DESCRIBE_BLOCK_NAME = combinedModule.ROOT_DESCRIBE_BLOCK_NAME 16 | exports.resetState = combinedModule.resetState 17 | exports.getState = combinedModule.getState 18 | exports.setState = combinedModule.setState 19 | exports.dispatch = combinedModule.dispatch 20 | exports.dispatchSync = combinedModule.dispatchSync 21 | exports.addEventHandler = combinedModule.addEventHandler 22 | 23 | -- ROBLOX deviation END 24 | 25 | return exports 26 | -------------------------------------------------------------------------------- /src/jest-mock/README.md: -------------------------------------------------------------------------------- 1 | # jest-mock 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-mock 4 | 5 | This package implements the various function and module mocking capabilities used by Jest. You can find its documentation in the [Jest documentation](https://roblox.github.io/jest-roblox-internal). 6 | 7 | --- 8 | 9 | ### :pencil2: Notes 10 | * As of right now, only a minimal set of functionality for jest-mock has been ported. The only externally facing functions that are supported are: 11 | * Creating an instance of the `ModuleMockerClass` via constructor (i.e. importing jest-mock and calling `.new()` on the import) 12 | * And then these functions are supported on an instance of the `ModuleMockerClass`: 13 | * `fn()` - create a function that can help in unit testing to confirm expectations on number of calls, returns, call arguments, etc. (currently this is mainly useful for the spyMatchers) 14 | * `clearAllMocks()` 15 | * `resetAllMocks()` 16 | * `restoreAllMocks()` 17 | -------------------------------------------------------------------------------- /src/jest-core/src/getProjectDisplayName.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-core/src/getProjectDisplayName.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent.Parent 10 | local LuauPolyfill = require(Packages.LuauPolyfill) 11 | local Boolean = LuauPolyfill.Boolean 12 | 13 | local exports = {} 14 | 15 | local typesModule = require(Packages.JestTypes) 16 | type Config_ProjectConfig = typesModule.Config_ProjectConfig 17 | 18 | local function getProjectDisplayName(projectConfig: Config_ProjectConfig): string | nil 19 | local ref = if typeof(projectConfig.displayName) == "table" then projectConfig.displayName.name else nil 20 | return Boolean.toJSBoolean(ref) and ref or nil 21 | end 22 | exports.default = getProjectDisplayName 23 | 24 | return exports 25 | -------------------------------------------------------------------------------- /src/jest-matcher-utils/README.md: -------------------------------------------------------------------------------- 1 | # jest-matcher-utils 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-matcher-utils 4 | 5 | This package's exports are mainly used by `expect`'s `utils`. 6 | 7 | --- 8 | 9 | ### :pencil2: Notes 10 | * We don't provide support for `bigint` types 11 | * We don't provide a translation for the `chalk` library. This also means we omit certain tests that rely on comparing output that is colored differently. 12 | * Changed type annotations in upstream that were `unknown` to `any` because Luau doesn't have support for an `unknown` type 13 | * In many of the tests, there is differentiation between types such as `Array` and `Map`, however in Lua all of these are treated identically as `table`. The tests were translated to use the `table` type and some tests were left out if they became identical to other tests or were highly redundant. 14 | * Luau does not yet have functionality to use generics in function signatures and functions so those type annotations are left out 15 | -------------------------------------------------------------------------------- /src/jest-runtime/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestRuntime" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | JestTypes = { path = "../jest-types" } 21 | JestMock = { path = '../jest-mock' } 22 | Expect = { path = "../expect" } 23 | JestFakeTimers = { path = "../jest-fake-timers" } 24 | JestSnapshot = { path = "../jest-snapshot" } 25 | JestMockGenv = { path = '../jest-mock-genv' } 26 | 27 | [dev_dependencies] 28 | JestEnvironmentLuau = { path = '../jest-environment-luau' } 29 | JestGlobals = { path = '../jest-globals' } 30 | JestConfig = { path = '../jest-config' } 31 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/state_.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-circus/src/state.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | -- ROBLOX deviation: moved implementation from `state.lua` to avoid cyclic dependencies 10 | local CurrentModule = script.Parent 11 | local Packages = CurrentModule.Parent.Parent 12 | 13 | local typesModule = require(Packages.JestTypes) 14 | type Circus_State = typesModule.Circus_State 15 | 16 | local STATE_SYM = require(script.Parent.types).STATE_SYM 17 | 18 | local exports = {} 19 | 20 | local ROOT_DESCRIBE_BLOCK_NAME = "ROOT_DESCRIBE_BLOCK" 21 | exports.ROOT_DESCRIBE_BLOCK_NAME = ROOT_DESCRIBE_BLOCK_NAME 22 | 23 | local function getState(): Circus_State 24 | return _G[STATE_SYM] 25 | end 26 | exports.getState = getState 27 | 28 | return exports 29 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids" 15 | }, 16 | "dependencies": { 17 | "@docusaurus/core": "^2.4.0", 18 | "@docusaurus/preset-classic": "^2.4.0", 19 | "@mdx-js/react": "^1.6.21", 20 | "clsx": "^1.1.1", 21 | "react": "^17.0.1", 22 | "react-dom": "^17.0.1" 23 | }, 24 | "browserslist": { 25 | "production": [ 26 | ">0.5%", 27 | "not dead", 28 | "not op_mini all" 29 | ], 30 | "development": [ 31 | "last 1 chrome version", 32 | "last 1 firefox version", 33 | "last 1 safari version" 34 | ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/jest-jasmine2/README.md: -------------------------------------------------------------------------------- 1 | # jest-jasmine2 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-jasmine2 4 | 5 | --- 6 | 7 | ### :pencil2: Notes 8 | * Our upstream, Jest, doesn't include any test files for the files in this directory, `jest-jasmine2/src/jasmine/`, so we look to the upstream that Jest is based off of Jasmine, for the test files 9 | * The tests for CallTracker and SpyStrategy are copied off of the upstream files but the `createSpy.ts` file doesn't actually have a direct upstream equivalent in Jasmine so we copy some tests from `SpySpec` instead, leaving out the majority of tests that aren't yet relevant 10 | * We expose `andAlso` in addition to the typical `and` for createSpy since `and` is a built in keyword for Lua so we can't cleanly chain fields (i.e. we can't get `var.and` to work so we allow for `var.andAlso`) 11 | * We use the [Roblox Lua Promise](https://github.com/evaera/roblox-lua-promise) library in this module in a number of places to more closely mirror the asynchronous tests in Jasmine 12 | -------------------------------------------------------------------------------- /src/jest-util/src/specialChars.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/specialChars.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local exports = {} 11 | 12 | -- local UserInputService = game:GetService("UserInputService") 13 | 14 | -- ROBLOX FIXME: make proper platform check 15 | -- local isWindows = process.platform == "win32" 16 | local isWindows = false -- UserInputService:GetPlatform() == 0 17 | local ARROW = " \u{203A} " 18 | exports.ARROW = ARROW 19 | local ICONS = { 20 | failed = if isWindows then "\u{00D7}" else "\u{2715}", 21 | pending = "\u{25CB}", 22 | success = if isWindows then "\u{221A}" else "\u{2713}", 23 | todo = "\u{270E}", 24 | } 25 | exports.ICONS = ICONS 26 | local CLEAR = if isWindows then "\x1B[2J\x1B[0f" else "\x1B[2J\x1B[3J\x1B[H" 27 | exports.CLEAR = CLEAR 28 | return exports 29 | -------------------------------------------------------------------------------- /src/jest/src/init.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest/src/jest.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent 10 | 11 | local exports = {} 12 | local coreModule = require(Packages.JestCore) 13 | exports.SearchSource = coreModule.SearchSource 14 | exports.TestWatcher = coreModule.TestWatcher 15 | exports.createTestScheduler = coreModule.createTestScheduler 16 | -- ROBLOX ROBLOX deviation START: not ported 17 | -- exports.getVersion = coreModule.getVersion 18 | -- ROBLOX deviation END 19 | exports.runCLI = coreModule.runCLI 20 | -- ROBLOX deviation START: JestCli is not ported 21 | -- exports.run = require(Packages.JestCli).run 22 | -- ROBLOX deviation END 23 | 24 | -- ROBLOX deviation: args handles arg parsing from ProcessService 25 | exports.args = require(script["args.roblox"]) 26 | 27 | return exports 28 | -------------------------------------------------------------------------------- /src/expect/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "Expect" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | RegExp = { workspace = true } 21 | JestGetType = { path = "../jest-get-type" } 22 | JestMessageUtil = { path = "../jest-message-util" } 23 | JestUtil = { path = "../jest-util" } 24 | JestMatcherUtils = { path = "../jest-matcher-utils" } 25 | JestSnapshot = { path = "../jest-snapshot" } 26 | RobloxShared = { path = "../roblox-shared" } 27 | 28 | [dev_dependencies] 29 | JestGlobals = { path = "../jest-globals" } 30 | JestMock = { path = "../jest-mock" } 31 | TestUtils = { path = "../test-utils" } 32 | ChalkLua = { workspace = true } 33 | -------------------------------------------------------------------------------- /src/jest-util/src/replacePathSepForGlob.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/replacePathSepForGlob.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | --[=[ 11 | ROBLOX deviation: not ported as it doesn't seem necessary in Lua 12 | 13 | local CurrentModule = script.Parent 14 | local Packages = CurrentModule.Parent 15 | local exports = {} 16 | 17 | local typesModule = require(Packages.JestTypes) 18 | type Config_Glob = typesModule.Config_Glob 19 | type Config_Path = typesModule.Config_Path 20 | 21 | local function replacePathSepForGlob(path: Config_Path): Config_Glob 22 | return path:replace( 23 | error("not implemented"), --[[ ROBLOX TODO: Unhandled node for type: RegExpLiteral ]] --[[ /\\(?![{}()+?.^$])/g ]] 24 | "/" 25 | ) 26 | end 27 | exports.default = replacePathSepForGlob 28 | return exports 29 | ]=] 30 | 31 | return {} 32 | -------------------------------------------------------------------------------- /src/jest-util/src/testPathPatternToRegExp.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/testPathPatternToRegExp.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent.Parent 10 | local RegExp = require(Packages.RegExp) 11 | type RegExp = RegExp.RegExp 12 | 13 | local exports = {} 14 | 15 | local typesModule = require(Packages.JestTypes) 16 | type Config_GlobalConfig = typesModule.Config_GlobalConfig 17 | 18 | -- Because we serialize/deserialize globalConfig when we spawn workers, 19 | -- we can't pass regular expression. Using this shared function on both sides 20 | -- will ensure that we produce consistent regexp for testPathPattern. 21 | exports.default = function(testPathPattern: typeof((({} :: any) :: Config_GlobalConfig).testPathPattern)): RegExp 22 | return RegExp(testPathPattern, "i") 23 | end 24 | 25 | return exports 26 | -------------------------------------------------------------------------------- /src/test-utils/src/init.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/test-utils/src/index.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- */ 8 | 9 | local CurrentModule = script 10 | 11 | local alignedAnsiStyleSerializer = require(CurrentModule.alignedAnsiStyleSerializer) 12 | local configModule = require(CurrentModule.config) 13 | 14 | --[[ 15 | ROBLOX deviation: ommiting ConditionalTest and config imports 16 | original code: 17 | export { 18 | isJestJasmineRun, 19 | skipSuiteOnJasmine, 20 | skipSuiteOnJestCircus, 21 | onNodeVersions, 22 | } from './ConditionalTest'; 23 | 24 | export {makeGlobalConfig, makeProjectConfig} from './config'; 25 | ]] 26 | 27 | return { 28 | alignedAnsiStyleSerializer = alignedAnsiStyleSerializer, 29 | makeGlobalConfig = configModule.makeGlobalConfig, 30 | makeProjectConfig = configModule.makeProjectConfig, 31 | } 32 | -------------------------------------------------------------------------------- /src/roblox-shared/src/getRelativePath.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local function getRelativePath(script_: Instance, rootDir: Instance?): string 18 | local path = script_.Name 19 | 20 | local curr: Instance = script_ 21 | while curr.Parent and curr ~= rootDir do 22 | curr = curr.Parent 23 | path = curr.Name .. "/" .. path 24 | end 25 | 26 | return if rootDir ~= nil then path else "/" .. path 27 | end 28 | 29 | return getRelativePath 30 | -------------------------------------------------------------------------------- /TestRoot/normalizeStackTraces.lua: -------------------------------------------------------------------------------- 1 | local function removeRootFromStackTrace(line: string): string 2 | return line:gsub("LoadedCode.JestRoblox.", ""):gsub("ReplicatedStorage.Packages.", "") 3 | end 4 | 5 | local function serialize(val: string | { [any]: any }, config, indentation, depth, refs, printer): string 6 | if typeof(val) == "table" then 7 | val.message = removeRootFromStackTrace(val.message) 8 | elseif typeof(val) == "string" then 9 | val = removeRootFromStackTrace(val) 10 | end 11 | 12 | return printer( 13 | val, 14 | config, 15 | indentation, 16 | depth, 17 | refs, 18 | printer 19 | ) 20 | end 21 | 22 | local function containsStackTrace(val: string): boolean 23 | return string.find(val, "%s*LoadedCode%.JestRoblox") ~= nil 24 | or string.find(val, "%s*ReplicatedStorage%.Packages") ~= nil 25 | end 26 | 27 | local function test(val: any): boolean 28 | return (typeof(val) == "string" and containsStackTrace(val)) or (typeof(val) == "table" and typeof(val.message) == "string" and containsStackTrace(val.message)) 29 | end 30 | 31 | return { 32 | serialize = serialize, 33 | test = test, 34 | } 35 | -------------------------------------------------------------------------------- /src/jest-circus/src/init.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: no upstream 2 | --[[ 3 | * Copyright (c) Roblox Corporation. All rights reserved. 4 | * Licensed under the MIT License (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://opensource.org/licenses/MIT 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ]] 16 | local circusModule = require(script.circus) 17 | 18 | local exports = circusModule 19 | 20 | export type Event = circusModule.Event 21 | export type State = circusModule.State 22 | 23 | -- ROBLOX deviation: exporting runner alongside the main entry point 24 | local runner = require(script.runner); 25 | (exports :: any).runner = runner 26 | 27 | return exports :: typeof(circusModule) & { runner: typeof(runner) } 28 | -------------------------------------------------------------------------------- /src/diff-sequences/src/__tests__/__snapshots__/index.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/diff-sequences/src/__tests__/__snapshots__/index.test.ts.snap 2 | 3 | local snapshots = {} 4 | 5 | snapshots["common substrings regression 1"] = [=[ 6 | 7 | Table { 8 | "I", 9 | " se", 10 | "e", 11 | " ", 12 | "a", 13 | " perfection ", 14 | "i", 15 | " att", 16 | "in", 17 | "e", 18 | " no", 19 | " ", 20 | "n", 21 | " i", 22 | " n", 23 | " ", 24 | "a", 25 | " ", 26 | "u", 27 | " ", 28 | "en", 29 | " ", 30 | "t", 31 | "er", 32 | " ", 33 | "is ", 34 | "n", 35 | "i", 36 | "n", 37 | " ", 38 | "r", 39 | "e", 40 | " ", 41 | " re", 42 | "e", 43 | ".", 44 | } 45 | ]=] 46 | 47 | snapshots["common substrings wrapping 1"] = [=[ 48 | 49 | Table { 50 | "When engineers ", 51 | "a", 52 | "v", 53 | "e", 54 | " ", 55 | "ready-to-use tools, they", 56 | " writ", 57 | " more", 58 | "tests, which", 59 | " results in", 60 | "more stabl", 61 | "e", 62 | " code bases.", 63 | } 64 | ]=] 65 | 66 | return snapshots 67 | -------------------------------------------------------------------------------- /src/jest-config/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestConfig" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | ChalkLua = { workspace = true } 21 | RegExp = { workspace = true } 22 | JestTypes = { path = "../jest-types" } 23 | JestGetType = { path = "../jest-get-type" } 24 | JestUtil = { path = "../jest-util" } 25 | JestEnvironmentLuau = { path = "../jest-environment-luau" } 26 | JestValidate = { path = "../jest-validate" } 27 | RobloxShared = { path = "../roblox-shared" } 28 | 29 | [dev_dependencies] 30 | JestGlobals = { path = "../jest-globals" } 31 | JestSnapshotSerializerRaw = { path = "../jest-snapshot-serializer-raw" } 32 | PrettyFormat = { path = "../pretty-format" } 33 | -------------------------------------------------------------------------------- /src/jest-snapshot-serializer-raw/src/init.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/ikatyang/jest-snapshot-serializer-raw/blob/v1.2.0/src/index.ts 2 | --[[ 3 | MIT License 4 | 5 | Copyright (c) Ika (https://github.com/ikatyang) 6 | ]] 7 | 8 | local Packages = script.Parent 9 | local LuauPolyfill = require(Packages.LuauPolyfill) 10 | local Symbol = LuauPolyfill.Symbol 11 | 12 | local always = require(script.always) 13 | 14 | local exports = {} 15 | 16 | local RAW = Symbol.for_("jest-snapshot-serializer-raw") 17 | 18 | export type Wrapper = { [any]: string } 19 | local function wrap(value: string): Wrapper 20 | return { [RAW] = value } 21 | end 22 | exports.wrap = wrap 23 | 24 | local function test( 25 | value: any 26 | ): boolean --[[ ROBLOX FIXME: change to TSTypePredicate equivalent if supported ]] --[[ value is Wrapper ]] 27 | return typeof(value) == "table" and always.test(value[RAW]) 28 | end 29 | exports.test = test 30 | 31 | local function print(value: Wrapper): string 32 | return always.print(value[RAW]) 33 | end 34 | exports.print = print 35 | 36 | exports.default = wrap 37 | 38 | return exports 39 | -------------------------------------------------------------------------------- /src/jest-benchmark/src/init.lua: -------------------------------------------------------------------------------- 1 | --!strict 2 | --[[ 3 | * Copyright (c) Roblox Corporation. All rights reserved. 4 | * Licensed under the MIT License (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://opensource.org/licenses/MIT 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ]] 16 | -- ROBLOX NOTE: no upstream 17 | 18 | local exports = {} 19 | 20 | exports.benchmark = require(script.benchmark).benchmark 21 | exports.Profiler = require(script.Profiler) 22 | exports.Reporter = require(script.reporters.Reporter) 23 | exports.HeartbeatReporter = require(script.reporters.HeartbeatReporter) 24 | exports.MetricLogger = require(script.MetricLogger) 25 | exports.CustomReporters = require(script.CustomReporters) 26 | 27 | return exports 28 | -------------------------------------------------------------------------------- /src/roblox-shared/src/__tests__/cleanLoadStringStack.spec.lua: -------------------------------------------------------------------------------- 1 | local CurrentModule = script.Parent 2 | local Packages = CurrentModule.Parent.Parent 3 | 4 | local JestGlobals = require(Packages.Dev.JestGlobals) 5 | local expect = JestGlobals.expect 6 | local it = JestGlobals.it 7 | 8 | local cleanLoadStringStack = require(CurrentModule.Parent.cleanLoadStringStack) 9 | 10 | it("should reformat a loadstring stacktrace to look like a normal stacktrace", function() 11 | local stack = 12 | [=[[string "_Workspace.JestCircus.JestCircus.circus.__tests__.formatNodeAssertErrors.roblox.spec"]:118]=] 13 | expect(cleanLoadStringStack(stack)).toEqual( 14 | "_Workspace.JestCircus.JestCircus.circus.__tests__.formatNodeAssertErrors.roblox.spec:118" 15 | ) 16 | end) 17 | 18 | it("should reformat a loadstring stacktrace with a function name to look like a normal stacktrace", function() 19 | local stack = [=[[string "_Workspace.JestMessageUtil.JestMessageUtil.__tests__.messages.roblox.spec"]:34: kaboom]=] 20 | expect(cleanLoadStringStack(stack)).toEqual( 21 | "_Workspace.JestMessageUtil.JestMessageUtil.__tests__.messages.roblox.spec:34: kaboom" 22 | ) 23 | end) 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2023 Roblox Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/jest-util/src/preRunMessage.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/preRunMessage.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local CurrentModule = script.Parent 11 | local Packages = CurrentModule.Parent 12 | local exports = {} 13 | 14 | local chalk = require(Packages.ChalkLua) 15 | local clearLine = require(script.Parent.clearLine).default 16 | local isInteractive = require(script.Parent.isInteractive).default 17 | 18 | local RobloxShared = require(Packages.RobloxShared) 19 | type Writeable = RobloxShared.Writeable 20 | 21 | local function print(stream: Writeable): () 22 | if isInteractive then 23 | stream:write(chalk.bold.dim("Determining test suites to run...")) 24 | end 25 | end 26 | exports.print = print 27 | 28 | local function remove(stream: Writeable): () 29 | if isInteractive then 30 | clearLine(stream) 31 | end 32 | end 33 | exports.remove = remove 34 | 35 | return exports 36 | -------------------------------------------------------------------------------- /src/jest-snapshot/src/types.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-snapshot/src/types.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- */ 8 | local CurrentModule = script.Parent 9 | local Packages = CurrentModule.Parent 10 | local LuauPolyfill = require(Packages.LuauPolyfill) 11 | type Object = LuauPolyfill.Object 12 | 13 | -- ROBLOX TODO: upstream is `MatcherState &`, which is from `expect` package, but would result in a circular rotriever dependency 14 | export type Context = Object 15 | 16 | export type MatchSnapshotConfig = { 17 | context: Context, 18 | hint: string?, 19 | inlineSnapshot: string?, 20 | isInline: boolean, 21 | matcherName: string, 22 | properties: Object?, 23 | received: any, 24 | } 25 | 26 | export type SnapshotData = { [string]: string } 27 | 28 | -- copied from `expect` - should be shared 29 | export type ExpectationResult = { 30 | pass: boolean, 31 | message: () -> string, 32 | } 33 | 34 | return {} 35 | -------------------------------------------------------------------------------- /src/jest-validate/src/init.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-validate/src/index.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local exports = {} 10 | 11 | local utilsModule = require(script.utils) 12 | exports.ValidationError = utilsModule.ValidationError 13 | export type ValidationError = utilsModule.ValidationError 14 | -- ROBLOX deviation START: not ported yet 15 | -- exports.createDidYouMeanMessage = utilsModule.createDidYouMeanMessage 16 | -- exports.format = utilsModule.format 17 | -- exports.logValidationWarning = utilsModule.logValidationWarning 18 | -- local typesModule = require(script.types) 19 | -- exports.DeprecatedOptions = typesModule.DeprecatedOptions 20 | -- exports.validate = require(script.validate).default 21 | -- exports.validateCLIOptions = require(script.validateCLIOptions).default 22 | -- exports.multipleValidOptions = require(script.condition).multipleValidOptions 23 | -- ROBLOX deviation END 24 | return exports 25 | -------------------------------------------------------------------------------- /src/jest-get-type/README.md: -------------------------------------------------------------------------------- 1 | # jest-get-type 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-get-type 4 | 5 | A utility function to get the type of a value, including Luau and Roblox types. 6 | 7 | Types supported: 8 | 9 | * Lua Primitives - `nil`, `table`, `number`, `string`, `function`, `boolean`, `userdata`, `thread` 10 | * [Luau Polyfill](https://github.com/Roblox/luau-polyfill) types - `symbol`, [`regexp`](https://github.com/Roblox/luau-regexp), `error`, `set` 11 | * Roblox datatypes - `DateTime`, and other [`builtin`](https://developer.roblox.com/en-us/api-reference/data-types) types 12 | 13 | --- 14 | 15 | ### :pencil2: Notes 16 | * Lua makes no distinction between tables, objects, and arrays. We always return `table` at this level and consumers are expected to check at a higher level. 17 | * Lua makes no distinction between `null` and `undefined` so we only return `nil`. 18 | * Lua lacks the following primitives: `bigint`, `symbol`. 19 | * Lua lacks the following built-in types: `RegExp`, `Map`, `Set`, `Date`. 20 | * `JestGetType` deviates and exposes an `isRobloxBuiltin` method to check whether a value is a Roblox builtin type 21 | -------------------------------------------------------------------------------- /src/jest-reporters/src/__tests__/__snapshots__/getSnapshotStatus.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-reporters/src/__tests__/__snapshots__/getSnapshotStatus.test.js.snap 2 | local exports = {} 3 | 4 | exports[ [=[Retrieves the snapshot status 1]=] ] = [=[ 5 | 6 | Table { 7 | " › 1 snapshot written.", 8 | " › 1 snapshot updated.", 9 | " › 1 snapshot failed.", 10 | " › 1 snapshot obsolete.", 11 | " • test suite with unchecked snapshot", 12 | } 13 | ]=] 14 | exports[ [=[Retrieves the snapshot status after a snapshot update 1]=] ] = [=[ 15 | 16 | Table { 17 | " › 2 snapshots written.", 18 | " › 2 snapshots updated.", 19 | " › 2 snapshots failed.", 20 | " › 2 snapshots removed.", 21 | " • first test suite with unchecked snapshot", 22 | " • second test suite with unchecked snapshot", 23 | " › snapshot file removed.", 24 | } 25 | ]=] 26 | exports[ [=[Shows no snapshot updates if all snapshots matched 1]=] ] = "Table {}" 27 | 28 | return exports 29 | -------------------------------------------------------------------------------- /src/jest-runner/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestRunner" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | ChalkLua = { workspace = true } 21 | JestTestResult = { path = "../jest-test-result" } 22 | JestTypes = { path = "../jest-types" } 23 | JestUtil = { path = "../jest-util" } 24 | JestConsole = { path = "../jest-console" } 25 | JestEnvironment = { path = "../jest-environment" } 26 | JestMessageUtil = { path = "../jest-message-util" } 27 | JestRuntime = { path = "../jest-runtime" } 28 | JestCircus = { path = "../jest-circus" } 29 | Throat = { path = "../throat" } 30 | Emittery = { path = "../emittery" } 31 | RobloxShared = { path = "../roblox-shared" } 32 | 33 | [dev_dependencies] 34 | JestGlobals = { path = "../jest-globals" } 35 | -------------------------------------------------------------------------------- /src/roblox-shared/src/ensureDirectoryExists.lua: -------------------------------------------------------------------------------- 1 | -- moved from jest-snapshot/utils.lua 2 | 3 | local Packages = script.Parent.Parent 4 | local LuauPolyfill = require(Packages.LuauPolyfill) 5 | local Error = LuauPolyfill.Error 6 | 7 | local getParent = require(script.Parent.getParent) 8 | local getDataModelService = require(script.Parent.getDataModelService) 9 | 10 | local FileSystemService = getDataModelService("FileSystemService") 11 | 12 | local function ensureDirectoryExists(filePath: string) 13 | -- ROBLOX deviation: gets path of parent directory, GetScriptFilePath can only be called on ModuleScripts 14 | local path = getParent(filePath, 1) 15 | local ok, err = pcall(function() 16 | if FileSystemService and not FileSystemService:Exists(path) then 17 | FileSystemService:CreateDirectories(path) 18 | end 19 | end) 20 | 21 | if not ok and err:find("Error%(13%): Access Denied%. Path is outside of sandbox%.") then 22 | error( 23 | Error.new( 24 | "Provided path is invalid: you likely need to provide a different argument to --fs.readwrite.\n" 25 | .. "You may need to pass in `--fs.readwrite=$PWD`" 26 | ) 27 | ) 28 | end 29 | end 30 | 31 | return ensureDirectoryExists 32 | -------------------------------------------------------------------------------- /src/jest-reporters/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestReporters" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | ChalkLua = { workspace = true } 20 | RegExp = { workspace = true } 21 | JestTypes = { path = "../jest-types" } 22 | JestTestResult = { path = '../jest-test-result' } 23 | JestMessageUtil = { path = "../jest-message-util" } 24 | JestUtil = { path = '../jest-util' } 25 | TestUtils = { path = '../test-utils' } 26 | JestConsole = { path = '../jest-console' } 27 | JestMock = { path = '../jest-mock' } 28 | RobloxShared = { path = '../roblox-shared' } 29 | Path = { path = '../path' } 30 | 31 | [dev_dependencies] 32 | JestGlobals = { path = "../jest-globals" } 33 | JestConfig = { path = "../jest-config" } 34 | PrettyFormat = { path = "../pretty-format" } 35 | JestSnapshotSerializerRaw = { path = "../jest-snapshot-serializer-raw" } 36 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/tryRealpath.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local CurrentModule = script.Parent 18 | local SrcModule = CurrentModule.Parent 19 | local Packages = SrcModule.Parent 20 | 21 | local JestGlobals = require(Packages.Dev.JestGlobals) 22 | local expect = JestGlobals.expect 23 | local describe = JestGlobals.describe 24 | local it = JestGlobals.it 25 | 26 | local tryRealpath = require(SrcModule.tryRealpath) 27 | 28 | describe("tryRealpath", function() 29 | it("should execute without error", function() 30 | expect(tryRealpath).toBeDefined() 31 | expect(tryRealpath).toEqual({}) 32 | end) 33 | end) 34 | -------------------------------------------------------------------------------- /src/jest-console/src/types.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-console/src/types.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local CurrentModule = script.Parent 10 | local Packages = CurrentModule.Parent 11 | 12 | local LuauPolyfill = require(Packages.LuauPolyfill) 13 | type Array = LuauPolyfill.Array 14 | 15 | local exports = {} 16 | 17 | export type LogMessage = string 18 | 19 | export type LogEntry = { message: LogMessage, origin: string, type: LogType } 20 | 21 | export type LogCounters = { [string]: number } 22 | 23 | export type LogTimers = { [string]: DateTime } 24 | 25 | export type LogType = 26 | "assert" 27 | | "count" 28 | | "debug" 29 | | "dir" 30 | | "dirxml" 31 | | "error" 32 | | "group" 33 | | "groupCollapsed" 34 | | "info" 35 | | "log" 36 | | "time" 37 | | "warn" 38 | 39 | export type ConsoleBuffer = Array 40 | 41 | -- ROBLOX deviation START: add type for supproted inspect options 42 | export type InspectOptions = { 43 | depth: number?, 44 | } 45 | -- Roblox deviation END 46 | 47 | return exports 48 | -------------------------------------------------------------------------------- /src/roblox-shared/src/pruneDeps.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | 16 | local loadModuleEnabled = pcall((debug :: any).loadmodule, Instance.new("ModuleScript")) 17 | 18 | local cleanLoadStringStack = require(script.Parent.cleanLoadStringStack) 19 | 20 | local function pruneDeps(str: string?): string? 21 | if str == nil then 22 | return nil 23 | end 24 | 25 | local newLines = {} 26 | for _, line in (str :: string):split("\n") do 27 | if line:find("_Index.") then 28 | continue 29 | end 30 | if not loadModuleEnabled then 31 | line = cleanLoadStringStack(line) 32 | end 33 | table.insert(newLines, line) 34 | end 35 | return table.concat(newLines, "\n") 36 | end 37 | 38 | return pruneDeps 39 | -------------------------------------------------------------------------------- /src/jest-mock-rbx/src/init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | --!strict 16 | -- ROBLOX NOTE: no upstream 17 | 18 | local CurrentModule = script 19 | local InstanceProxy = require(CurrentModule.InstanceProxy) 20 | local DataModelMocker = require(CurrentModule.DataModelMocker) 21 | 22 | export type InstanceProxy = InstanceProxy.InstanceProxy 23 | export type Spied = InstanceProxy.Spied 24 | export type ProxyControls = InstanceProxy.ProxyControls 25 | 26 | export type DataModelMocker = DataModelMocker.DataModelMocker 27 | 28 | local exports = {} 29 | 30 | exports.DataModelMocker = DataModelMocker 31 | 32 | return exports 33 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/requireOrImportModule.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local CurrentModule = script.Parent 18 | local SrcModule = CurrentModule.Parent 19 | local Packages = SrcModule.Parent 20 | 21 | local JestGlobals = require(Packages.Dev.JestGlobals) 22 | local expect = JestGlobals.expect 23 | local describe = JestGlobals.describe 24 | local it = JestGlobals.it 25 | local requireOrImportModule = require(SrcModule.requireOrImportModule) 26 | 27 | describe("requireOrImportModule", function() 28 | it("should execute without error", function() 29 | expect(requireOrImportModule).toBeDefined() 30 | expect(requireOrImportModule).toEqual({}) 31 | end) 32 | end) 33 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/interopRequireDefault.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local CurrentModule = script.Parent 18 | local SrcModule = CurrentModule.Parent 19 | local Packages = SrcModule.Parent 20 | 21 | local JestGlobals = require(Packages.Dev.JestGlobals) 22 | local expect = JestGlobals.expect 23 | local describe = JestGlobals.describe 24 | local it = JestGlobals.it 25 | 26 | local interopRequireDefault = require(SrcModule.interopRequireDefault) 27 | 28 | describe("interopRequireDefault", function() 29 | it("should execute without error", function() 30 | expect(interopRequireDefault).toBeDefined() 31 | expect(interopRequireDefault).toEqual({}) 32 | end) 33 | end) 34 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/replacePathSepForGlob.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local CurrentModule = script.Parent 18 | local SrcModule = CurrentModule.Parent 19 | local Packages = SrcModule.Parent 20 | 21 | local JestGlobals = require(Packages.Dev.JestGlobals) 22 | local expect = JestGlobals.expect 23 | local describe = JestGlobals.describe 24 | local it = JestGlobals.it 25 | 26 | local replacePathSepForGlob = require(SrcModule.replacePathSepForGlob) 27 | 28 | describe("replacePathSepForGlob", function() 29 | it("should execute without error", function() 30 | expect(replacePathSepForGlob).toBeDefined() 31 | expect(replacePathSepForGlob).toEqual({}) 32 | end) 33 | end) 34 | -------------------------------------------------------------------------------- /src/jest-types/src/TestResult.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-types/src/TestResult.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local rootWorkspace = script.Parent.Parent 10 | local LuauPolyfill = require(rootWorkspace.LuauPolyfill) 11 | type Array = LuauPolyfill.Array 12 | 13 | export type Milliseconds = number 14 | 15 | export type Status = "passed" | "failed" | "skipped" | "pending" | "todo" | "disabled" 16 | 17 | export type Callsite = { column: number, line: number } 18 | 19 | -- this is here to make it possible to avoid huge dependency trees just for types 20 | export type AssertionResult = { 21 | ancestorTitles: Array, 22 | duration: (Milliseconds | nil)?, 23 | failureDetails: Array, 24 | failureMessages: Array, 25 | fullName: string, 26 | invocations: number?, 27 | location: (Callsite | nil)?, 28 | numPassingAsserts: number, 29 | retryReasons: Array?, 30 | status: Status, 31 | title: string, 32 | } 33 | 34 | export type SerializableError = { 35 | code: any?, 36 | message: string, 37 | stack: string | nil, 38 | type: string?, 39 | } 40 | 41 | return {} 42 | -------------------------------------------------------------------------------- /src/expect/src/__tests__/__snapshots__/roblox.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- Jest Roblox Snapshot v1, http://roblox.github.io/jest-roblox-internal/snapshot-testing 2 | local exports = {} 3 | exports[ [=[assertions & hasAssertions assertions fails 1]=] ] = [=[ 4 | 5 | "expect.assertions(4) 6 | 7 | Expected four assertions to be called but received three assertion calls." 8 | ]=] 9 | 10 | exports[ [=[assertions & hasAssertions assertions fails 2]=] ] = [=[ 11 | 12 | "Error: expect.assertions(4) 13 | 14 | Expected four assertions to be called but received three assertion calls. 15 | _Workspace.Expect.Expect.__tests__.roblox.spec:47 16 | _Workspace.JestCircus.JestCircus.circus.utils:369 17 | " 18 | ]=] 19 | 20 | exports[ [=[assertions & hasAssertions hasAssertions fails 1]=] ] = [=[ 21 | 22 | "expect.hasAssertions() 23 | 24 | Expected at least one assertion to be called but received none." 25 | ]=] 26 | 27 | exports[ [=[assertions & hasAssertions hasAssertions fails 2]=] ] = [=[ 28 | 29 | "Error: expect.hasAssertions() 30 | 31 | Expected at least one assertion to be called but received none. 32 | _Workspace.Expect.Expect.__tests__.roblox.spec:72 33 | _Workspace.JestCircus.JestCircus.circus.utils:369 34 | " 35 | ]=] 36 | 37 | return exports 38 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/testPathPatternToRegExp.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local CurrentModule = script.Parent 18 | local SrcModule = CurrentModule.Parent 19 | local Packages = SrcModule.Parent 20 | 21 | local JestGlobals = require(Packages.Dev.JestGlobals) 22 | local expect = JestGlobals.expect 23 | local describe = JestGlobals.describe 24 | local it = JestGlobals.it 25 | 26 | local testPathPatternToRegExp = require(SrcModule.testPathPatternToRegExp) 27 | 28 | describe("testPathPatternToRegExp", function() 29 | it("should execute without error", function() 30 | expect(testPathPatternToRegExp).toBeDefined() 31 | expect(typeof(testPathPatternToRegExp.default)).toEqual("function") 32 | end) 33 | end) 34 | -------------------------------------------------------------------------------- /src/roblox-shared/src/Writeable.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream: replaces node js writeable stream API 16 | 17 | export type Writeable = { 18 | isTTY: boolean?, 19 | write: (self: Writeable, data: string) -> (), 20 | } 21 | 22 | local Writeable = {} 23 | Writeable.__index = Writeable 24 | 25 | function Writeable.new(options: { write: (data: string) -> () }?): Writeable 26 | local self = setmetatable({}, Writeable) 27 | self._writeFn = if options ~= nil and typeof(options.write) == "function" then options.write else print 28 | self.isTTY = false 29 | return (self :: any) :: Writeable 30 | end 31 | 32 | function Writeable:write(data: string) 33 | self._writeFn(data) 34 | end 35 | 36 | return { 37 | Writeable = Writeable, 38 | } 39 | -------------------------------------------------------------------------------- /src/jest-config/src/__tests__/validatePattern.spec.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-config/src/__tests__/validatePattern.test.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | * 8 | ]] 9 | 10 | local Packages = script.Parent.Parent.Parent 11 | local JestGlobals = require(Packages.Dev.JestGlobals) 12 | local expect = JestGlobals.expect 13 | local describe = JestGlobals.describe 14 | local it = JestGlobals.it 15 | 16 | local validatePattern = require(script.Parent.Parent.validatePattern).default 17 | 18 | describe("validate pattern function", function() 19 | it("without passed args returns true", function() 20 | local isValid = validatePattern() 21 | expect(isValid).toBeTruthy() 22 | end) 23 | 24 | it("returns true for empty pattern", function() 25 | local isValid = validatePattern("") 26 | expect(isValid).toBeTruthy() 27 | end) 28 | 29 | it("returns true for valid pattern", function() 30 | local isValid = validatePattern("abc+") 31 | expect(isValid).toBeTruthy() 32 | end) 33 | 34 | it("returns false for invalid pattern", function() 35 | local isValid = validatePattern("\\") 36 | expect(isValid).toBeFalsy() 37 | end) 38 | end) 39 | -------------------------------------------------------------------------------- /src/jest-message-util/src/__tests__/__snapshots__/messages.roblox.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- Jest Roblox Snapshot v1, http://roblox.github.io/jest-roblox-internal/snapshot-testing 2 | local exports = {} 3 | exports[ [=[.formatExecError() - Promise throw Error 1]=] ] = [=[ 4 | 5 | " ● Test suite failed to run 6 | 7 | kaboom 8 | 9 | _Workspace.JestMessageUtil.JestMessageUtil.__tests__.messages.roblox.spec:49 10 | " 11 | ]=] 12 | 13 | exports[ [=[.formatExecError() - Promise throw string 1]=] ] = [=[ 14 | 15 | " ● Test suite failed to run 16 | 17 | _Workspace.JestMessageUtil.JestMessageUtil.__tests__.messages.roblox.spec:34: kaboom 18 | 19 | _Workspace.JestMessageUtil.JestMessageUtil.__tests__.messages.roblox.spec:34 20 | " 21 | ]=] 22 | 23 | exports[ [=[.formatExecError() - nested Promise throw Error 1]=] ] = [=[ 24 | 25 | " ● Test suite failed to run 26 | 27 | kaboom 28 | 29 | _Workspace.JestMessageUtil.JestMessageUtil.__tests__.messages.roblox.spec:82 30 | " 31 | ]=] 32 | 33 | exports[ [=[.formatExecError() - nested Promise throw string 1]=] ] = [=[ 34 | 35 | " ● Test suite failed to run 36 | 37 | _Workspace.JestMessageUtil.JestMessageUtil.__tests__.messages.roblox.spec:65: kaboom 38 | 39 | _Workspace.JestMessageUtil.JestMessageUtil.__tests__.messages.roblox.spec:65 40 | " 41 | ]=] 42 | 43 | return exports 44 | -------------------------------------------------------------------------------- /src/expect/src/jestMatchersObject_extracted.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/expect/src/jestMatchersObject.ts 2 | -- ROBLOX NOTE: extracted from jestMatchersObject.lua to avoid circular dependencies 3 | -- /** 4 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | -- * 6 | -- * This source code is licensed under the MIT license found in the 7 | -- * LICENSE file in the root directory of this source tree. 8 | -- * 9 | -- */ 10 | 11 | local CurrentModule = script.Parent 12 | local Packages = CurrentModule.Parent 13 | 14 | local LuauPolyfill = require(Packages.LuauPolyfill) 15 | local Symbol = LuauPolyfill.Symbol 16 | 17 | local Types = require(CurrentModule.types) 18 | type MatcherState = Types.MatcherState 19 | 20 | -- Global matchers object holds the list of available matchers and 21 | -- the state, that can hold matcher specific values that change over time. 22 | local JEST_MATCHERS_OBJECT = Symbol.for_("$$jest-matchers-object") 23 | 24 | --[[ 25 | ROBLOX TODO: add default generic param when possible 26 | original code: 27 | export const getState = (): State => 28 | ]] 29 | local function getState(): State 30 | return _G[JEST_MATCHERS_OBJECT].state 31 | end 32 | 33 | return { 34 | JEST_MATCHERS_OBJECT = JEST_MATCHERS_OBJECT, 35 | getState = getState, 36 | } 37 | -------------------------------------------------------------------------------- /src/jest-each/README.md: -------------------------------------------------------------------------------- 1 | # jest-each 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-each 4 | 5 | A parameterized testing library for Jest. You can find its documentation in the [Jest documentation](https://roblox.github.io/jest-roblox-internal). 6 | 7 | --- 8 | 9 | ### :pencil2: Notes 10 | * Deviations: 11 | * Tagged templates are not available in Lua. As an alternative, a headings string must be used with a list of arrays containing the same amount of items as headings. 12 | Example: 13 | ```lua 14 | each("a | b | expected", 15 | { 0, 0, 0 }, 16 | { 0, 1, 1 }, 17 | { 1, 1, 2 } 18 | ).it("returns $expected when given $a and $b", 19 | function(ref) 20 | local a: number, b: number, expected = ref.a, ref.b, ref.expected 21 | jestExpect(a + b).toBe(expected) 22 | end 23 | ) 24 | ``` 25 | * Use `NIL` provided constant instead of nil when passing values to each 26 | ```lua 27 | each("expected", { NIL }).it( 28 | "templates properly convert $expected to nil before running the tests", 29 | function(ref) 30 | jestExpect(ref.expected).toBe(nil) 31 | end 32 | ) 33 | ``` 34 | * TestEZ methods are supported (`*FOCUS`, `*SKIP`), however, these may be dropped at some point in favor of jest's callable objects(`it`, `it.only`, `it.skip`), which are supported too 35 | -------------------------------------------------------------------------------- /src/jest-runtime/src/__tests__/test_root/root.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/jest-runtime/src/__tests__/test_root/root.js 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | * 8 | ]] 9 | local Packages = script.Parent.Parent.Parent.Parent 10 | local JestGlobals = require(Packages.Dev.JestGlobals) 11 | local jest = JestGlobals.jest 12 | 13 | local exports = {} 14 | -- ROBLOX deviation START: using ModuleScript instead of path 15 | -- require("ExclusivelyManualMock") 16 | -- require_("ManuallyMocked") 17 | -- require_("ModuleWithSideEffects") 18 | -- require_("ModuleWithState") 19 | -- require_("RegularModule") -- We only care about the static analysis, not about the runtime. 20 | -- local function lazyRequire() 21 | -- require_("image!not_really_a_module") 22 | -- require_("cat.png") 23 | -- require_("dog.png") 24 | -- end 25 | -- exports.lazyRequire = lazyRequire 26 | -- require(script.Parent.ExclusivelyManualMock) 27 | require(script.Parent.ManuallyMocked) 28 | -- require(script.Parent.ModuleWithSideEffects) 29 | -- require(script.Parent.ModuleWithState) 30 | require(script.Parent.RegularModule) 31 | -- ROBLOX deviation END 32 | 33 | exports.jest = jest 34 | 35 | return exports 36 | -------------------------------------------------------------------------------- /src/jest-circus/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestCircus" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | RegExp = { workspace = true } 21 | ChalkLua = { workspace = true } 22 | JestTypes = { path = "../jest-types" } 23 | JestMatcherUtils = { path = "../jest-matcher-utils" } 24 | JestMessageUtil = { path = "../jest-message-util" } 25 | PrettyFormat = { path = "../pretty-format" } 26 | JestEach = { path = "../jest-each" } 27 | JestUtil = { path = "../jest-util" } 28 | JestTestResult = { path = "../jest-test-result" } 29 | JestEnvironment = { path = "../jest-environment" } 30 | JestSnapshot = { path = "../jest-snapshot" } 31 | Expect = { path = "../expect" } 32 | RobloxShared = { path = "../roblox-shared" } 33 | JestRuntime = { path = "../jest-runtime" } 34 | Throat = { path = "../throat" } 35 | 36 | [dev_dependencies] 37 | JestGlobals = { path = "../jest-globals" } 38 | JestSnapshotSerializerRaw = { path = "../jest-snapshot-serializer-raw" } 39 | -------------------------------------------------------------------------------- /src/jest-benchmark/src/reporters/FpsReporter.lua: -------------------------------------------------------------------------------- 1 | --!strict 2 | --[[ 3 | * Copyright (c) Roblox Corporation. All rights reserved. 4 | * Licensed under the MIT License (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://opensource.org/licenses/MIT 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ]] 16 | -- ROBLOX NOTE: no upstream 17 | 18 | local exports = {} 19 | 20 | local initializeHeartbeatReporter = require(script.Parent.HeartbeatReporter).initializeHeartbeatReporter 21 | 22 | local function averageFps(deltaTimeList: { number }) 23 | if #deltaTimeList == 0 then 24 | return math.huge 25 | end 26 | 27 | local sum = 0 28 | for _, deltaTime in deltaTimeList do 29 | sum += deltaTime 30 | end 31 | local averageDeltaTime = sum / #deltaTimeList 32 | return 1 / averageDeltaTime 33 | end 34 | 35 | local function initializeFpsReporter() 36 | return initializeHeartbeatReporter("FPS", averageFps) 37 | end 38 | exports.initializeFpsReporter = initializeFpsReporter 39 | 40 | return exports 41 | -------------------------------------------------------------------------------- /src/jest-util/src/getFileSystemService.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local CurrentModule = script.Parent 18 | local Packages = CurrentModule.Parent 19 | local LuauPolyfill = require(Packages.LuauPolyfill) 20 | local Error = LuauPolyfill.Error 21 | 22 | local RobloxShared = require(Packages.RobloxShared) 23 | local getDataModelService = RobloxShared.getDataModelService 24 | 25 | local function getFileSystemService() 26 | local success, result = pcall(function() 27 | return _G.__MOCK_FILE_SYSTEM__ or getDataModelService("FileSystemService") 28 | end) 29 | 30 | if not success then 31 | error(Error.new("Attempting to save snapshots in an environment where FileSystemService is inaccessible.")) 32 | end 33 | 34 | return result 35 | end 36 | 37 | return getFileSystemService 38 | -------------------------------------------------------------------------------- /src/jest-core/rotriever.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "JestCore" 3 | authors = { workspace = true } 4 | description = { workspace = true } 5 | repository = { workspace = true } 6 | homepage = { workspace = true } 7 | documentation = { workspace = true } 8 | keywords = { workspace = true } 9 | version = { workspace = true } 10 | license = { workspace = true } 11 | content_root = "src" 12 | files = ["*", "!**/__*__/**"] 13 | 14 | [config] 15 | registry_index = "true" 16 | 17 | [dependencies] 18 | LuauPolyfill = { workspace = true } 19 | Promise = { workspace = true } 20 | ChalkLua = { workspace = true } 21 | RegExp = { workspace = true } 22 | JestConfig = { path = "../jest-config" } 23 | JestConsole = { path = "../jest-console" } 24 | JestTestResult = { path = "../jest-test-result" } 25 | JestTypes = { path = "../jest-types" } 26 | JestRuntime = { path = "../jest-runtime" } 27 | JestRunner = { path = "../jest-runner" } 28 | JestReporters = { path = "../jest-reporters" } 29 | JestUtil = { path = "../jest-util" } 30 | JestMessageUtil = { path = "../jest-message-util" } 31 | JestSnapshot = { path = "../jest-snapshot" } 32 | PrettyFormat = { path = "../pretty-format" } 33 | RobloxShared = { path = "../roblox-shared" } 34 | Emittery = { path = "../emittery" } 35 | 36 | [dev_dependencies] 37 | JestGlobals = { path = "../jest-globals" } 38 | JestSnapshotSerializerRaw = { path = "../jest-snapshot-serializer-raw" } 39 | TestUtils = { path = "../test-utils" } 40 | -------------------------------------------------------------------------------- /src/jest-benchmark/src/MetricLogger.lua: -------------------------------------------------------------------------------- 1 | --!strict 2 | --[[ 3 | * Copyright (c) Roblox Corporation. All rights reserved. 4 | * Licensed under the MIT License (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://opensource.org/licenses/MIT 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ]] 16 | -- ROBLOX NOTE: no upstream 17 | 18 | local Packages = script:FindFirstAncestor("JestBenchmark").Parent 19 | local LuauPolyfill = require(Packages.LuauPolyfill) 20 | local console = LuauPolyfill.console 21 | 22 | export type metricLoggerFn = (metricName: string, value: any) -> () 23 | 24 | local function defaultMetricLogger(metricName: string, value: any) 25 | console.log(`{metricName}, {value}`) 26 | end 27 | 28 | local MetricLogger = { 29 | log = defaultMetricLogger, 30 | } 31 | 32 | MetricLogger.useCustomMetricLogger = function(customMetricLogger: metricLoggerFn) 33 | MetricLogger.log = customMetricLogger 34 | end 35 | 36 | MetricLogger.useDefaultMetricLogger = function() 37 | MetricLogger.log = defaultMetricLogger 38 | end 39 | 40 | return MetricLogger 41 | -------------------------------------------------------------------------------- /src/jest-globals/src/__tests__/index.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-globals/src/__tests__/index.ts 16 | 17 | return (function() 18 | type Function = (...any) -> ...any 19 | 20 | local JestGlobals = require(script.Parent.Parent) 21 | local expect = JestGlobals.expect 22 | local test = JestGlobals.test 23 | 24 | test("throw when directly imported", function() 25 | expect(function() 26 | require(script.Parent.Parent.index) 27 | end).toThrowError( 28 | -- ROBLOX deviation START: aligned message to make sense for jest-roblox 29 | "Do not import `JestGlobals` outside of the Jest 3 test environment.\n" 30 | .. "Tip: Jest 2 uses a different pattern - check your Jest version." 31 | -- ROBLOX deviation END 32 | ) 33 | end) 34 | 35 | return {} 36 | end)() 37 | -------------------------------------------------------------------------------- /src/jest-snapshot/src/plugins.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-snapshot/src/plugins.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- */ 8 | 9 | local CurrentModule = script.Parent 10 | local Packages = CurrentModule.Parent 11 | 12 | local jestMockSerializer = require(CurrentModule.mockSerializer) 13 | 14 | local prettyFormat = require(Packages.PrettyFormat) 15 | type PrettyFormatPlugins = prettyFormat.Plugins 16 | local plugins = require(Packages.PrettyFormat).plugins 17 | -- ROBLOX deviation: omitting DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent 18 | 19 | -- ROBLOX TODO: ADO-1182 Add more plugins here as we translate them 20 | local PLUGINS: PrettyFormatPlugins = { 21 | jestMockSerializer, 22 | plugins.AsymmetricMatcher, 23 | plugins.ReactElement, 24 | plugins.ReactTestComponent, 25 | -- ROBLOX deviation: Roblox Instance matchers 26 | plugins.RobloxInstance, 27 | } 28 | 29 | -- Prepend to list so the last added is the first tested. 30 | local function addSerializer(plugin_) 31 | table.insert(PLUGINS, 1, plugin_) 32 | end 33 | 34 | local function getSerializers() 35 | return PLUGINS 36 | end 37 | 38 | return { 39 | addSerializer = addSerializer, 40 | getSerializers = getSerializers, 41 | } 42 | -------------------------------------------------------------------------------- /src/jest-util/src/formatTime.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/formatTime.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local exports = {} 11 | 12 | -- ROBLOX deviation START: Polyfill Math.trunc 13 | local function mathTrunc(value: number): number 14 | return if value > 0 then math.floor(value) else math.ceil(value) 15 | end 16 | -- ROBLOX deviation END 17 | -- ROBLOX deviation START: Polyfill String.padStart 18 | local function stringPadStart(str: string, targetLength_: number, padString_: string?) 19 | local targetLength = math.max(#str, targetLength_) 20 | 21 | local padString = padString_ or " " 22 | return (padString:rep(targetLength) .. str):sub(-targetLength) 23 | end 24 | -- ROBLOX deviation END 25 | 26 | local function formatTime(time: number, prefixPower_: number?, padLeftLength_: number?): string 27 | local prefixPower = prefixPower_ or -3 28 | local padLeftLength = padLeftLength_ or 0 29 | local prefixes = { "n", "μ", "m", "" } 30 | local prefixIndex = math.max(0, math.min(mathTrunc(prefixPower / 3) + #prefixes - 1, #prefixes - 1)) + 1 31 | return ("%s %ss"):format(stringPadStart(tostring(time), padLeftLength), prefixes[prefixIndex]) 32 | end 33 | exports.default = formatTime 34 | return exports 35 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/__tests__/eventHandler.spec.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: no upstream 2 | local CurrentModule = script.Parent 3 | local SrcModule = CurrentModule.Parent 4 | local Packages = SrcModule.Parent.Parent 5 | 6 | local JestGlobals = require(Packages.Dev.JestGlobals) 7 | local expect = JestGlobals.expect 8 | local describe = JestGlobals.describe 9 | local it = JestGlobals.it 10 | 11 | local RegExp = require(Packages.RegExp) 12 | local eventHandler = require(CurrentModule.Parent.eventHandler).default 13 | 14 | local typesModule = require(Packages.JestTypes) 15 | type Circus_Event = typesModule.Circus_Event 16 | type Circus_State = typesModule.Circus_State 17 | 18 | describe("eventHandler", function() 19 | it("should not fail when called with testNamePattern", function() 20 | local event = ({ name = "setup", testNamePattern = "apattern" } :: any) :: Circus_Event 21 | local state = {} :: Circus_State 22 | expect(function() 23 | eventHandler(nil, event, state) 24 | end).never.toThrow() 25 | end) 26 | 27 | it("should add testNamePattern to the state", function() 28 | local pattern = "apattern" 29 | local event = ({ name = "setup", testNamePattern = pattern } :: any) :: Circus_Event 30 | local state = {} :: Circus_State 31 | eventHandler(nil, event, state) 32 | 33 | expect(state.testNamePattern).toBeDefined() 34 | expect(state.testNamePattern).toBeInstanceOf(RegExp) 35 | expect(state.testNamePattern).toEqual(RegExp(pattern, "i")) 36 | end) 37 | end) 38 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/testCaseReportHandler.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-circus/src/testCaseReportHandler.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local CurrentModule = script.Parent 10 | local Packages = CurrentModule.Parent.Parent 11 | local exports = {} 12 | local testResultModule = require(Packages.JestTestResult) 13 | type TestFileEvent = testResultModule.TestFileEvent 14 | local typesModule = require(Packages.JestTypes) 15 | type Circus_Event = typesModule.Circus_Event 16 | local utilsModule = require(script.Parent.utils) 17 | local makeSingleTestResult = utilsModule.makeSingleTestResult 18 | local parseSingleTestResult = utilsModule.parseSingleTestResult 19 | 20 | local function testCaseReportHandler(testPath: string, sendMessageToJest: TestFileEvent) 21 | return function(_self, event: Circus_Event): () 22 | if event.name == "test_done" then 23 | local testResult = makeSingleTestResult(event.test) 24 | local testCaseResult = parseSingleTestResult(testResult) 25 | -- ROBLOX FIXME Luau: roblox-cli doesn't allow for mixed arrays 26 | sendMessageToJest("test-case-result", { testPath :: any, testCaseResult }) 27 | end 28 | end 29 | end 30 | 31 | exports.default = testCaseReportHandler 32 | 33 | return exports 34 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/__tests__/circusItOnlyFailingTest.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License") 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | local CurrentModule = script.Parent 17 | local SrcModule = CurrentModule.Parent 18 | local Packages = SrcModule.Parent.Parent 19 | 20 | local JestGlobals = require(Packages.Dev.JestGlobals) 21 | local expect = JestGlobals.expect 22 | local describe = JestGlobals.describe 23 | local jest = JestGlobals.jest 24 | local it = JestGlobals.it 25 | local afterAll = JestGlobals.afterAll 26 | 27 | describe("it.only.failing works", function() 28 | local fail = jest.fn(function() 29 | expect(true).toBe(false) 30 | end) 31 | afterAll(function() 32 | expect(fail).toHaveBeenCalledTimes(1) 33 | end) 34 | 35 | it.only.failing("only this test should run", function() 36 | fail() 37 | end) 38 | it.failing("skip failing test", function() 39 | fail() 40 | end) 41 | end) 42 | -------------------------------------------------------------------------------- /src/jest-circus/src/circus/types.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-circus/src/types.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local CurrentModule = script.Parent 10 | local Packages = CurrentModule.Parent.Parent 11 | local LuauPolyfill = require(Packages.LuauPolyfill) 12 | local Symbol = LuauPolyfill.Symbol 13 | 14 | local exports = {} 15 | 16 | -- Used as type 17 | local typesModule = require(Packages.JestTypes) 18 | type Circus_State = typesModule.Circus_State 19 | local expect = require(Packages.Expect) 20 | 21 | local STATE_SYM = (Symbol("JEST_STATE_SYMBOL") :: unknown) :: "STATE_SYM_SYMBOL" 22 | exports.STATE_SYM = STATE_SYM 23 | local RETRY_TIMES = (Symbol.for_("RETRY_TIMES") :: unknown) :: "RETRY_TIMES_SYMBOL" 24 | exports.RETRY_TIMES = RETRY_TIMES 25 | -- To pass this value from Runtime object to state we need to use global[sym] 26 | local TEST_TIMEOUT_SYMBOL = (Symbol.for_("TEST_TIMEOUT_SYMBOL") :: unknown) :: "TEST_TIMEOUT_SYMBOL" 27 | exports.TEST_TIMEOUT_SYMBOL = TEST_TIMEOUT_SYMBOL 28 | 29 | -- ROBLOX NOTE: can't declare type within a global namespace in Luau 30 | export type NodeJS_Global = { 31 | STATE_SYM_SYMBOL: Circus_State, 32 | RETRY_TIMES_SYMBOL: string, 33 | TEST_TIMEOUT_SYMBOL: number, 34 | expect: typeof(expect), 35 | } 36 | 37 | return exports 38 | -------------------------------------------------------------------------------- /src/jest-benchmark/src/CustomReporters.lua: -------------------------------------------------------------------------------- 1 | --!strict 2 | --[[ 3 | * Copyright (c) Roblox Corporation. All rights reserved. 4 | * Licensed under the MIT License (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://opensource.org/licenses/MIT 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ]] 16 | -- ROBLOX NOTE: no upstream 17 | 18 | local Packages = script:FindFirstAncestor("JestBenchmark").Parent 19 | local Object = require(Packages.LuauPolyfill).Object 20 | 21 | local reporterModule = require(script.Parent.reporters.Reporter) 22 | type Reporter = reporterModule.Reporter 23 | type ReporterMap = { [string]: Reporter } 24 | 25 | local exports = {} 26 | 27 | local customReporters: ReporterMap = {} 28 | exports.customReporters = customReporters 29 | 30 | local function useCustomReporters(reporters: ReporterMap) 31 | Object.assign(exports.customReporters, reporters) 32 | end 33 | exports.useCustomReporters = useCustomReporters 34 | 35 | local function useDefaultReporters() 36 | table.clear(exports.customReporters) 37 | end 38 | exports.useDefaultReporters = useDefaultReporters 39 | 40 | return exports 41 | -------------------------------------------------------------------------------- /src/pretty-format/src/__tests__/__snapshots__/react.spec.snap.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/pretty-format/src/__tests__/__snapshots__/react.test.tsx.snap 2 | 3 | -- Jest Snapshot v1, https://goo.gl/fbAQLP 4 | local exports = {} 5 | 6 | exports["ReactElement plugin highlights syntax 1"] = [[ 7 | 8 | " 9 | prop={ 10 |
11 | mouse 12 | 13 | rat 14 | 15 |
16 | } 17 | />" 18 | ]] 19 | exports["ReactElement plugin highlights syntax with color from theme option 1"] = [[ 20 | 21 | " 22 | style=\"color:red\" 23 | > 24 | Hello, Mouse! 25 | " 26 | ]] 27 | exports["ReactTestComponent plugin highlights syntax 1"] = [[ 28 | 29 | " 30 | prop={ 31 |
32 | mouse 33 | 34 | rat 35 | 36 |
37 | } 38 | />" 39 | ]] 40 | exports["ReactTestComponent plugin highlights syntax with color from theme option 1"] = [[ 41 | 42 | " 43 | style=\"color:red\" 44 | > 45 | Hello, Mouse! 46 | " 47 | ]] 48 | exports["ReactTestComponent removes undefined props 1"] = [[ 49 | 50 | " 51 | xyz={true} 52 | />" 53 | ]] 54 | 55 | return exports 56 | -------------------------------------------------------------------------------- /src/pretty-format/README.md: -------------------------------------------------------------------------------- 1 | # pretty-format 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/pretty-format 4 | 5 | Stringify any Luau value 6 | * Supports Luau builtins and Roblox Instances. 7 | * Can be extended with user defined plugins. 8 | 9 | --- 10 | 11 | ### :pencil2: Notes 12 | * :warning: Our `prettyFormat` doesn't distinguish between `Tables`, `Arrays`, `Objects`, etc. and prints out all Lua table-like types as `Table`. 13 | * For example, an empty array is printed as `Table {}` and an array with values is printed as `Table {1, 2, 3,}`. 14 | * `printComplexValue` is reduced to just arrays and tables. 15 | * :x: Color formatting isn't supported so all related methods are omitted. 16 | * :hammer: Built-in plugins for `prettyFormat` are not implemented yet. 17 | * `prettyFormat` formats Roblox `DateTime` objects as a replacement for JS `Date`. 18 | * Formats using the Lua native string representations of primitives like `nil`, `nan` and `inf` over the JS `null`, `NaN` and `Infinity`. The tests are modified accordingly. 19 | * Formatting for any Javascript specific types in are omitted, `Symbol`, named `Function`, `Error`, `Date`, `BigInt`, etc. 20 | * `getConfig` is rewritten to avoid ternary operators. 21 | loop is rewritten with a `for` loop instead of an `iterator.next()`. 22 | * `Collections.lua` deviates from upstream substantially since Lua only has tables. We only have two functions: `printTableEntries` for formatting key, value pairs and `printListItems` for formatting arrays. 23 | -------------------------------------------------------------------------------- /src/jest-diff/README.md: -------------------------------------------------------------------------------- 1 | # jest-diff 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-diff 4 | 5 | Display differences clearly so people can review changes confidently. 6 | 7 | The `diff` named export serializes **values**, compares them line-by-line, and returns a string which includes comparison lines. 8 | 9 | Two named exports compare **strings** character-by-character: 10 | 11 | - `diffStringsUnified` returns a string. 12 | - `diffStringsRaw` returns an array of `Diff` objects. 13 | 14 | Three named exports compare **arrays of strings** line-by-line: 15 | 16 | - `diffLinesUnified` and `diffLinesUnified2` return a string. 17 | - `diffLinesRaw` returns an array of `Diff` objects. 18 | 19 | --- 20 | 21 | ### :pencil2: Notes 22 | * `CleanupSemantic.lua` is adapted from the Lua version of [`diff-match-patch`](https://github.com/google/diff-match-patch/blob/master/lua/diff_match_patch.lua) to resemble the upstream [`cleanupSemantics.ts`](https://github.com/facebook/jest/blob/v27.4.7/packages/jest-diff/src/cleanupSemantic.ts) instead of being a direct port of it. 23 | * Tests for it are added, which are not included in the upstream `jest-diff 24 | * Changes to tests: 25 | * Snapshots in `Diff.spec.lua` have their leading ``, ``, ``, and `` ANSI style codes manually removed. 26 | * Color formatting specific tests are omitted. 27 | * `changeColor` is assigned to a function that imitates `chalk.inverse` so we can test `diffStringsUnified`. 28 | * `Array[]`, `Object{}` are changed to `Table{}`. 29 | -------------------------------------------------------------------------------- /src/jest-mock-rbx/README.md: -------------------------------------------------------------------------------- 1 | # jest-mock-rbx 2 | 3 | *No upstream. Roblox only.* 4 | 5 | This package implements Jest's data model mocking capabilities for Roblox: 6 | 7 | * `InstanceProxy`, used for constructing objects that act like an existing 8 | instance, except actions can be intercepted and mocked. 9 | * `DataModelMocker`, provides higher-level proxies that can interact with each 10 | other as part of a fake data model. 11 | 12 | --- 13 | 14 | ### :pencil2: Notes 15 | * Right now, only a limited subset of data model mocking features are 16 | implemented and available for use. 17 | * `DataModelMocker` should be used for constructing instance mocks, not 18 | `InstanceProxy`. 19 | * The `InstanceProxy` class is a minimal, self-contained implementation with 20 | no special behaviour. 21 | * The `DataModelMocker` class allows proxies to be reused, and provides 22 | useful default mock behaviour like returning proxied descendants or ancestry. 23 | * `InstanceProxy` intentionally only implements some of an `Instance`'s 24 | capabilities. 25 | * It is assumed that the instance proxy is being used on normal, idiomatic 26 | code that would correctly function if given an `Instance`. 27 | * Instance proxies have normal reference-based equality. They are not equal 28 | to the original instance, nor to any other proxies of that instance. 29 | * Instance proxies can't be consumed by functions expecting a "proper 30 | Instance". 31 | * In particular, calls to C such as `x:IsAncestorOf(InstanceProxy)` will 32 | error as these calls are not mockable. 33 | 34 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/isPromise.spec.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/__tests__/isPromise.test.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local CurrentModule = script.Parent.Parent 11 | local Packages = CurrentModule.Parent 12 | local Promise = require(Packages.Promise) 13 | local LuauPolyfill = require(Packages.LuauPolyfill) 14 | local Symbol = LuauPolyfill.Symbol 15 | local isPromise = require(CurrentModule.isPromise).default 16 | 17 | local JestGlobals = require(Packages.Dev.JestGlobals) 18 | local expect = JestGlobals.expect 19 | local describe = JestGlobals.describe 20 | local it = JestGlobals.it 21 | 22 | describe("foo", function() 23 | describe("not a Promise: ", function() 24 | it("nil", function() 25 | expect(isPromise(nil)).toBe(false) 26 | end) 27 | 28 | -- ROBLOX FIXME: have to cast first Array element to `any` to avoid type narrowing issue 29 | for _, value in ipairs({ true :: any, 42, "1337", Symbol(), {} }) do 30 | it(tostring(value), function() 31 | expect(isPromise(value)).toBe(false) 32 | end) 33 | end 34 | end) 35 | 36 | it("a resolved Promise", function() 37 | expect(isPromise(Promise.resolve(42))).toBe(true) 38 | end) 39 | 40 | it("a rejected Promise", function() 41 | expect(isPromise(Promise.reject():catch(function() end))).toBe(true) 42 | end) 43 | end) 44 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/pluralize.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local CurrentModule = script.Parent 18 | local SrcModule = CurrentModule.Parent 19 | local Packages = SrcModule.Parent 20 | 21 | local JestGlobals = require(Packages.Dev.JestGlobals) 22 | local expect = JestGlobals.expect 23 | local describe = JestGlobals.describe 24 | local it = JestGlobals.it 25 | 26 | local pluralize = require(SrcModule.pluralize).default 27 | 28 | describe("pluralize", function() 29 | it("should not pluralize when count is 1", function() 30 | expect(pluralize("test", 1)).toEqual("1 test") 31 | end) 32 | 33 | it("should pluralize when count is 0", function() 34 | expect(pluralize("test", 0)).toEqual("0 tests") 35 | end) 36 | 37 | it("should pluralize when count is more than 1", function() 38 | for i = 2, 100 do 39 | expect(pluralize("test", i)).toEqual(tostring(i) .. " tests") 40 | end 41 | end) 42 | end) 43 | -------------------------------------------------------------------------------- /src/jest-fake-timers/README.md: -------------------------------------------------------------------------------- 1 | # jest-fake-timers 2 | 3 | Upstream: https://github.com/facebook/jest/tree/v27.4.7/packages/jest-fake-timers 4 | 5 | This package contains the fake timers implementation for Jest. It can be activated by calling `jest.useFakeTimers()`. You can find its documentation in the [Jest documentation](https://roblox.github.io/jest-roblox-internal). 6 | 7 | The following timers are mocked: 8 | * `delay` 9 | * `tick` 10 | * `time` 11 | * `os` 12 | * `os.time` 13 | * `os.clock` 14 | * `task.delay` 15 | * `task.delay` 16 | * `task.cancel` 17 | * `task.wait` 18 | * `DateTime` 19 | 20 | --- 21 | 22 | ### :pencil2: Notes 23 | :exclamation: The fake timer API in Jest Roblox is aligned with the "modern" fake timer implementation in Jest. However, the actual implementation of fake timers in Jest Roblox under the hood massively deviates from upstream so that it works natively with the Roblox ecosystem. 24 | 25 | Similar to how Jest fake timers work by mocking the native timer functions (i.e. `setTimeout`, `setInterval`, `clearTimeout`, `clearInterval`) and `Date`, Jest Roblox fake timers work by mocking the native timer functions in Roblox (i.e. `delay`, `tick`), the Roblox `DateTime` and the Lua native timer methods `os.time` and `os.clock`. 26 | Additionally, Jest Roblox fake timers support a configurable engine frame time. By default, the engine frame time is 0 (i.e. continuous time), but if set, Jest Roblox fake timers will be processed by multiples of frame time. If engine frame time is set, then timers will be processed in the first frame after they are triggered. 27 | -------------------------------------------------------------------------------- /src/jest-snapshot/src/__tests__/missingSnapshotFile.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | 17 | local CurrentModule = script.Parent.Parent 18 | local Packages = CurrentModule.Parent 19 | 20 | local JestGlobals = require(Packages.Dev.JestGlobals) 21 | local expect = JestGlobals.expect 22 | local it = JestGlobals.it 23 | 24 | -- ROBLOX FIXME START: we can't call toMatchSnapshot and expect it to fail as this would affect the test state 25 | it.skip("tests that a missing snapshot file throws", function() 26 | expect(function() 27 | expect(nil :: any).toMatchSnapshot() 28 | end).toThrow( 29 | "Snapshot name: `tests that a missing snapshot file throws 1`\n\nNew snapshot was not written. The update flag must be explicitly passed to write a new snapshot.\n\nThis is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default." 30 | ) 31 | end) 32 | -- ROBLOX FIXME END 33 | -------------------------------------------------------------------------------- /src/jest-matcher-utils/src/deepCyclicCopyReplaceable.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-matcher-utils/src/deepCyclicCopyReplaceable.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- */ 8 | 9 | -- ROBLOX deviation: omitted isBuiltInObject and isMap functions because Lua only has one type, the table, 10 | -- for structuring data 11 | 12 | local deepCyclicCopyTable, deepCyclicCopyReplaceable 13 | 14 | type anyTable = { [any]: any } 15 | 16 | function deepCyclicCopyTable(tableToCopy: anyTable, cycles: anyTable) 17 | local newTable: anyTable = {} 18 | 19 | cycles[tableToCopy] = newTable 20 | 21 | for key, value in pairs(tableToCopy) do 22 | newTable[key] = deepCyclicCopyReplaceable(value, cycles) 23 | end 24 | 25 | return newTable 26 | end 27 | 28 | function deepCyclicCopyReplaceable(value: any, cycles: anyTable) 29 | if typeof(value) ~= "table" then 30 | return value 31 | elseif cycles[value] then 32 | return cycles[value] 33 | else 34 | local t = deepCyclicCopyTable(value, cycles) 35 | local mt = getmetatable(value) 36 | if mt and typeof(mt) == "table" then 37 | setmetatable(t, mt) 38 | end 39 | return t 40 | end 41 | end 42 | 43 | return function(value, cycles_: anyTable?) 44 | local cycles = cycles_ or {} 45 | setmetatable(cycles :: any, { _mode = "kv" }) 46 | 47 | return deepCyclicCopyReplaceable(value, cycles) 48 | end 49 | -------------------------------------------------------------------------------- /src/jest-diff/src/PrettyFormat.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | -- ROBLOX TODO: fix PrettyFormat types imports 17 | 18 | type CompareKeys = ((a: string, b: string) -> number) | nil 19 | 20 | type Plugin = any 21 | 22 | export type Plugins = { [number]: Plugin } 23 | 24 | type ThemeReceived = { 25 | comment: string?, 26 | content: string?, 27 | prop: string?, 28 | tag: string?, 29 | value: string?, 30 | } 31 | 32 | export type PrettyFormatOptions = { 33 | callToJSON: boolean?, 34 | compareKeys: CompareKeys, 35 | escapeRegex: boolean?, 36 | escapeString: boolean?, 37 | highlight: boolean?, 38 | indent: number?, 39 | maxDepth: number?, 40 | min: boolean?, 41 | plugins: Plugins?, 42 | printBasicPrototype: boolean?, 43 | printInstanceDefaults: boolean?, 44 | printFunctionName: boolean?, 45 | redactStackTracesInStrings: boolean?, 46 | theme: ThemeReceived?, 47 | } 48 | 49 | export type OptionsReceived = PrettyFormatOptions 50 | 51 | return {} 52 | -------------------------------------------------------------------------------- /src/jest-snapshot/src/PrettyFormat.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX NOTE: no upstream 16 | -- ROBLOX TODO: fix PrettyFormat types imports 17 | 18 | type CompareKeys = ((a: string, b: string) -> number) | nil 19 | 20 | type Plugin = any 21 | 22 | export type Plugins = { [number]: Plugin } 23 | 24 | type ThemeReceived = { 25 | comment: string?, 26 | content: string?, 27 | prop: string?, 28 | tag: string?, 29 | value: string?, 30 | } 31 | 32 | export type PrettyFormatOptions = { 33 | callToJSON: boolean?, 34 | compareKeys: CompareKeys, 35 | escapeRegex: boolean?, 36 | escapeString: boolean?, 37 | highlight: boolean?, 38 | indent: number?, 39 | maxDepth: number?, 40 | min: boolean?, 41 | plugins: Plugins?, 42 | printBasicPrototype: boolean?, 43 | printInstanceDefaults: boolean?, 44 | printFunctionName: boolean?, 45 | redactStackTracesInStrings: boolean?, 46 | theme: ThemeReceived?, 47 | } 48 | 49 | export type OptionsReceived = PrettyFormatOptions 50 | 51 | return {} 52 | -------------------------------------------------------------------------------- /src/jest-matcher-utils/src/Replaceable.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-matcher-utils/src/Replaceable.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- */ 8 | 9 | local CurrentModule = script.Parent 10 | local Packages = CurrentModule.Parent 11 | local getType = require(Packages.JestGetType).getType 12 | 13 | type ReplaceableForEachCallBack = (any, any, any) -> nil 14 | 15 | local Replaceable = {} 16 | 17 | Replaceable.__index = Replaceable 18 | function Replaceable.new(object: any) 19 | local self = {} 20 | self.object = object 21 | self.type = getType(object) 22 | 23 | if self.type ~= "table" then 24 | error("Type " .. self.type .. " is not supported in Replaceable!") 25 | end 26 | 27 | setmetatable(self, Replaceable) 28 | 29 | return self 30 | end 31 | 32 | function Replaceable.isReplaceable(obj1: any, obj2: any): boolean 33 | local obj1Type = getType(obj1) 34 | local obj2Type = getType(obj2) 35 | 36 | return obj1Type == obj2Type and obj1Type == "table" 37 | end 38 | 39 | function Replaceable:forEach(callback: ReplaceableForEachCallBack) 40 | for key, value in pairs(self.object) do 41 | callback(value, key, self.object) 42 | end 43 | end 44 | 45 | function Replaceable:get(key: any): any 46 | return self.object[key] 47 | end 48 | 49 | function Replaceable:set(key: any, value: any) 50 | self.object[key] = value 51 | end 52 | 53 | return Replaceable 54 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/errorWithStack.spec.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/__tests__/errorWithStack.test.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local CurrentModule = script.Parent.Parent 11 | local Packages = CurrentModule.Parent 12 | local LuauPolyfill = require(Packages.LuauPolyfill) 13 | local Error = LuauPolyfill.Error 14 | local ErrorWithStack = require(CurrentModule.ErrorWithStack).default 15 | 16 | local JestGlobals = require(Packages.Dev.JestGlobals) 17 | local jest = JestGlobals.jest 18 | local expect = JestGlobals.expect 19 | local describe = JestGlobals.describe 20 | local it = JestGlobals.it 21 | 22 | describe("ErrorWithStack", function() 23 | local message = "💩 something went wrong" 24 | local function callsite() end 25 | it("calls Error.captureStackTrace with given callsite when capture exists", function() 26 | local originalCaptureStackTrace = Error["captureStackTrace"] 27 | local captureStackTraceSpy = jest.fn() 28 | Error["captureStackTrace"] = captureStackTraceSpy 29 | -- jest.spyOn(Error, "captureStackTrace") 30 | local actual = ErrorWithStack.new(message, callsite) 31 | expect(actual).toBeInstanceOf(Error) 32 | expect(actual.message).toBe(message) 33 | expect(Error["captureStackTrace"]).toHaveBeenCalledWith(actual, callsite) 34 | 35 | Error["captureStackTrace"] = originalCaptureStackTrace 36 | end) 37 | end) 38 | -------------------------------------------------------------------------------- /src/jest-util/src/ErrorWithStack.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/tree/v28.0.0/packages/jest-util/src/ErrorWithStack.ts 2 | 3 | --[[* 4 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 5 | * 6 | * This source code is licensed under the MIT license found in the 7 | * LICENSE file in the root directory of this source tree. 8 | ]] 9 | 10 | local CurrentModule = script.Parent 11 | local Packages = CurrentModule.Parent 12 | local LuauPolyfill = require(Packages.LuauPolyfill) 13 | local Boolean = LuauPolyfill.Boolean 14 | local Error = LuauPolyfill.Error 15 | type Error = LuauPolyfill.Error 16 | local exports = {} 17 | 18 | export type ErrorWithStack = Error & {} 19 | local ErrorWithStack = setmetatable({}, { __index = Error }) 20 | ErrorWithStack.__index = ErrorWithStack 21 | function ErrorWithStack.new( 22 | message: string | nil, 23 | callsite: (...any) -> ...unknown, 24 | stackLimit: number? 25 | ): ErrorWithStack 26 | -- Ensure we have a large stack length so we get full details. 27 | local originalStackLimit = Error["stackTraceLimit"] 28 | if stackLimit ~= nil and stackLimit ~= 0 then 29 | Error["stackTraceLimit"] = 30 | math.max(stackLimit, Boolean.toJSBoolean(originalStackLimit) and originalStackLimit or 10) 31 | end 32 | 33 | local self = setmetatable(Error.new(message), ErrorWithStack) 34 | if Error.captureStackTrace then 35 | Error.captureStackTrace((self :: any) :: ErrorWithStack, callsite) 36 | end 37 | Error["stackTraceLimit"] = originalStackLimit 38 | return (self :: any) :: ErrorWithStack 39 | end 40 | exports.default = ErrorWithStack 41 | return exports 42 | -------------------------------------------------------------------------------- /src/jest-core/src/lib/createContext.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-core/src/lib/createContext.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent.Parent.Parent 10 | 11 | local exports = {} 12 | 13 | local typesModule = require(Packages.JestTypes) 14 | type Config_ProjectConfig = typesModule.Config_ProjectConfig 15 | -- ROBLOX deviation START: no haste maps support 16 | -- local jest_haste_mapModule = require(Packages["jest-haste-map"]) 17 | -- type HasteMapObject = jest_haste_mapModule.HasteMapObject 18 | type HasteMapObject = nil 19 | -- ROBLOX deviation END 20 | local jest_runtimeModule = require(Packages.JestRuntime) 21 | -- local Runtime = jest_runtimeModule.default 22 | type Context = jest_runtimeModule.Context 23 | 24 | -- ROBLOX deviation START: no haste maps support 25 | -- local function createContext(config: Config_ProjectConfig, ref0: HasteMapObject): TestContext 26 | -- local hasteFS, moduleMap = ref.hasteFS, ref.moduleMap 27 | -- ROBLOX deviation END 28 | local function createContext(config: Config_ProjectConfig, _ref: HasteMapObject): Context 29 | return { 30 | config = config, 31 | -- ROBLOX deviation START: no haste maps support 32 | -- hasteFS = hasteFS, 33 | -- moduleMap = moduleMap, 34 | -- resolver = Runtime:createResolver(config, moduleMap), 35 | -- ROBLOX deviation END 36 | } 37 | end 38 | exports.default = createContext 39 | 40 | return exports 41 | -------------------------------------------------------------------------------- /src/jest-runtime/src/_types.lua: -------------------------------------------------------------------------------- 1 | --[[* 2 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | ]] 7 | -- ROBLOX NOTE: Not paired with upstream. Just using for the "Jest Object" type 8 | 9 | local CurrentModule = script.Parent 10 | local Packages = CurrentModule.Parent 11 | 12 | local JestFakeTimers = require(Packages.JestFakeTimers) 13 | type FakeTimers = JestFakeTimers.FakeTimers 14 | 15 | local moduleMockerModule = require(Packages.JestMock) 16 | type ModuleMocker = moduleMockerModule.ModuleMocker 17 | 18 | export type MockFactory = () -> ...unknown 19 | 20 | export type Jest = { 21 | -- autoMockOn: () -> Jest, 22 | -- autoMockOff: () -> Jest, 23 | -- disableAutomock: () -> Jest, 24 | -- enableAutomock: () -> Jest, 25 | -- mock: (scriptInstance: ModuleScript, mockFactory: MockFactory, options: any) -> Jest, 26 | clearAllMocks: () -> Jest, 27 | resetAllMocks: () -> Jest, 28 | restoreAllMocks: () -> Jest, 29 | useFakeTimers: () -> Jest, 30 | useRealTimers: () -> Jest, 31 | resetModules: () -> Jest, 32 | isolateModules: (fn: () -> ()) -> Jest, 33 | fn: () -> ModuleMocker, 34 | -- genMockFromModule: (scriptInstance: ModuleScript) -> any, 35 | getRealSystemTime: () -> (), 36 | getTimerCount: () -> number, 37 | runAllTicks: () -> (), 38 | runAllTimers: () -> (), 39 | runOnlyPendingTimers: () -> (), 40 | -- setMock: (scriptInstance: ModuleScript, mock: unknown, options: { virtual: boolean? }?) -> Jest, 41 | setSystemTime: (now: (number | DateTime)?) -> (), 42 | setTimeout: any, 43 | } 44 | 45 | return {} 46 | -------------------------------------------------------------------------------- /src/jest-test-result/src/__tests__/formatTestResults.spec.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-test-result/src/__tests__/formatTestResults.test.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local CurrentModule = script.Parent.Parent 10 | local Packages = CurrentModule.Parent 11 | 12 | local JestGlobals = require(Packages.Dev.JestGlobals) 13 | local expect = JestGlobals.expect 14 | local describe = JestGlobals.describe 15 | local it = JestGlobals.it 16 | 17 | local formatTestResults = require(CurrentModule.formatTestResults).default 18 | 19 | local types = require(CurrentModule.types) 20 | type AggregatedResult = types.AggregatedResult 21 | 22 | describe("formatTestResults", function() 23 | local assertion = { 24 | fullName = "TestedModule#aMethod when some condition is met returns true", 25 | status = "passed", 26 | title = "returns true", 27 | } 28 | 29 | -- ROBLOX deviation START - casted to any, TS should fail here 30 | local results: AggregatedResult = { 31 | testResults = { 32 | { 33 | numFailingTests = 0, 34 | perfStats = { end_ = 2, runtime = 1, slow = false, start = 1 }, -- @ts-expect-error 35 | testResults = { assertion }, 36 | }, 37 | }, 38 | } :: any 39 | -- ROBLOX deviation END 40 | 41 | it("includes test full name", function() 42 | local result = formatTestResults(results, nil, nil) 43 | expect(result.testResults[1].assertionResults[1].fullName).toEqual(assertion.fullName) 44 | end) 45 | end) 46 | -------------------------------------------------------------------------------- /src/roblox-shared/src/redactStackTrace.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | 16 | local TRACE_LINE = `[%w_%-]+%.[%w_%-%.]+%:%d+[%w \t_]*` 17 | local REDACT_TRACE_WITH = ("\nRedacted.Stack.Trace:1337 function epicDuck"):rep(4):sub(2) 18 | local LUA_ERROR_LINE = `[%w_%-]+%.[%w_%-%.]+%:%d+%:[%w \t_]*` 19 | local REDACT_LUA_ERROR_WITH = "Redacted.Stack.Trace:1337: The epic duck is coming!" 20 | 21 | local function redactStackTrace(str: string?): string? 22 | if str == nil then 23 | return nil 24 | else 25 | local newLines = {} 26 | local lastLineRedacted = false 27 | for _, line in (str :: string):split("\n") do 28 | local lineWithRedactions = line:gsub(TRACE_LINE, if lastLineRedacted then "" else REDACT_TRACE_WITH) 29 | :gsub(LUA_ERROR_LINE, if lastLineRedacted then "" else REDACT_LUA_ERROR_WITH) 30 | lastLineRedacted = line ~= lineWithRedactions 31 | if not lastLineRedacted or lineWithRedactions:match("%S") then 32 | table.insert(newLines, lineWithRedactions) 33 | end 34 | end 35 | return table.concat(newLines, "\n") 36 | end 37 | end 38 | 39 | return redactStackTrace 40 | -------------------------------------------------------------------------------- /src/jest-core/src/lib/logDebugMessages.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-core/src/lib/logDebugMessages.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent.Parent.Parent 10 | local LuauPolyfill = require(Packages.LuauPolyfill) 11 | type Array = LuauPolyfill.Array 12 | 13 | local exports = {} 14 | 15 | local typesModule = require(Packages.JestTypes) 16 | type Config_GlobalConfig = typesModule.Config_GlobalConfig 17 | type Config_ProjectConfig = typesModule.Config_ProjectConfig 18 | -- ROBLOX FIXME START: no version available 19 | -- local VERSION = require_("../../package.json").version -- if the output here changes, update `getConfig` in e2e/runJest.ts 20 | local VERSION = "27.4.7" 21 | -- ROBLOX FIXME END 22 | 23 | -- ROBLOX deviation START: added missing variables to limit nr deviations 24 | local RobloxShared = require(Packages.RobloxShared) 25 | local nodeUtils = RobloxShared.nodeUtils 26 | type NodeJS_WriteStream = RobloxShared.NodeJS_WriteStream 27 | local JSON = nodeUtils.JSON 28 | -- ROBLOX deviation END 29 | 30 | local function logDebugMessages( 31 | globalConfig: Config_GlobalConfig, 32 | configs: Array | Config_ProjectConfig, 33 | outputStream: NodeJS_WriteStream 34 | ): () 35 | local output = { configs = configs, globalConfig = globalConfig, version = VERSION } 36 | outputStream:write((JSON.stringify(output, nil, " ")) .. "\n") 37 | end 38 | exports.default = logDebugMessages 39 | 40 | return exports 41 | -------------------------------------------------------------------------------- /src/roblox-shared/src/__tests__/Writeable.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | -- ROBLOX note: no upstream 16 | 17 | local CurrentModule = script.Parent 18 | local Packages = CurrentModule.Parent.Parent 19 | 20 | local Writeable = require(CurrentModule.Parent.Writeable).Writeable 21 | 22 | local JestConfig = require(Packages.Dev.JestConfig) 23 | 24 | local ModuleMocker = require(Packages.JestMock).ModuleMocker 25 | local JestGlobals = require(Packages.Dev.JestGlobals) 26 | local expect = JestGlobals.expect 27 | local describe = JestGlobals.describe 28 | local it = JestGlobals.it 29 | 30 | local moduleMocker = ModuleMocker.new(JestConfig.projectDefaults) 31 | local mockWrite = moduleMocker:fn() 32 | 33 | describe("Writeable", function() 34 | it("takes a write function and returns a writeable object with the write method attached", function() 35 | local writeFn = function(data: string) 36 | mockWrite(data) 37 | end 38 | local writeable = Writeable.new({ write = writeFn }) 39 | writeable:write("Hello, world!") 40 | expect(mockWrite).toBeCalledWith("Hello, world!") 41 | end) 42 | end) 43 | -------------------------------------------------------------------------------- /src/jest-config/src/color.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-config/src/color.ts 2 | --[[* 3 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | * 5 | * This source code is licensed under the MIT license found in the 6 | * LICENSE file in the root directory of this source tree. 7 | ]] 8 | 9 | local Packages = script.Parent.Parent 10 | local LuauPolyfill = require(Packages.LuauPolyfill) 11 | type Array = LuauPolyfill.Array 12 | local exports = {} 13 | -- local createHash = require(Packages.crypto).createHash 14 | -- ROBLOX deviation START: inline as ChalkLua doesn't export this type 15 | -- local chalkModule = require(Packages.chalk) 16 | type ForegroundColor = 17 | "black" 18 | | "red" 19 | | "green" 20 | | "yellow" 21 | | "blue" 22 | | "magenta" 23 | | "cyan" 24 | | "white" 25 | | "gray" 26 | | "grey" 27 | | "blackBright" 28 | | "redBright" 29 | | "greenBright" 30 | | "yellowBright" 31 | | "blueBright" 32 | | "magentaBright" 33 | | "cyanBright" 34 | | "whiteBright" 35 | -- ROBLOX deviation END 36 | type Color = ForegroundColor 37 | 38 | local colors: Array = { "red", "green", "yellow", "blue", "magenta", "cyan", "white" } 39 | 40 | local function getDisplayNameColor(seed: string?): Color 41 | if seed == nil then 42 | return "white" 43 | end 44 | 45 | -- ROBLOX deviation START: randomize color using math.random 46 | -- local hash = createHash("sha256") 47 | -- hash:update(seed) 48 | -- local num = hash:digest():readUInt32LE(0) 49 | local num = math.random(#colors) 50 | return colors[num] 51 | -- ROBLOX deviation END 52 | end 53 | exports.getDisplayNameColor = getDisplayNameColor 54 | 55 | return exports 56 | -------------------------------------------------------------------------------- /src/jest/src/__tests__/roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --!strict 2 | --[[ 3 | * Copyright (c) Roblox Corporation. All rights reserved. 4 | * Licensed under the MIT License (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://opensource.org/licenses/MIT 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | ]] 16 | -- ROBLOX NOTE: no upstream 17 | 18 | local CurrentModule = script.Parent.Parent 19 | local Packages = CurrentModule.Parent 20 | 21 | local JestGlobals = require(Packages.Dev.JestGlobals) 22 | local expect = JestGlobals.expect 23 | local describe = JestGlobals.describe 24 | local it = JestGlobals.it 25 | 26 | local jestModule = require(CurrentModule) 27 | 28 | describe("Jest", function() 29 | describe("re-exports JestCore", function() 30 | it("SearchSource", function() 31 | expect(jestModule.SearchSource).toBeDefined() 32 | end) 33 | 34 | it("TestWatcher", function() 35 | expect(jestModule.TestWatcher).toBeDefined() 36 | end) 37 | 38 | it("createTestScheduler", function() 39 | expect(jestModule.createTestScheduler).toBeDefined() 40 | end) 41 | 42 | -- ROBLOX NOTE: not ported 43 | it.skip("getVersion", function() 44 | -- expect(jestModule.getVersion).toBeDefined() 45 | end) 46 | 47 | it("runCLI", function() 48 | expect(jestModule.runCLI).toBeDefined() 49 | end) 50 | end) 51 | end) 52 | -------------------------------------------------------------------------------- /src/jest-diff/src/__tests__/DiffStringsRaw.spec.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-diff/src/__tests__/diffStringsRaw.test.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- */ 8 | 9 | local CurrentModule = script.Parent.Parent 10 | local Packages = CurrentModule.Parent 11 | 12 | local JestGlobals = require(Packages.Dev.JestGlobals) 13 | local expect = JestGlobals.expect 14 | local describe = JestGlobals.describe 15 | local it = JestGlobals.it 16 | 17 | local DIFF_DELETE = require(CurrentModule).DIFF_DELETE 18 | local DIFF_EQUAL = require(CurrentModule).DIFF_EQUAL 19 | local DIFF_INSERT = require(CurrentModule).DIFF_INSERT 20 | local Diff = require(CurrentModule).Diff 21 | local diffStringsRaw = require(CurrentModule).diffStringsRaw 22 | 23 | describe("diffStringsRaw", function() 24 | it("one-line with cleanup", function() 25 | local expected = { 26 | Diff.new(DIFF_EQUAL, "change "), 27 | Diff.new(DIFF_DELETE, "from"), 28 | Diff.new(DIFF_INSERT, "to"), 29 | } 30 | local received = diffStringsRaw("change from", "change to", true) 31 | expect(received).toEqual(expected) 32 | end) 33 | 34 | it("one-line without cleanup", function() 35 | local expected = { 36 | Diff.new(DIFF_EQUAL, "change "), 37 | Diff.new(DIFF_DELETE, "fr"), 38 | Diff.new(DIFF_INSERT, "t"), 39 | Diff.new(DIFF_EQUAL, "o"), 40 | Diff.new(DIFF_DELETE, "m"), 41 | } 42 | local received = diffStringsRaw("change from", "change to", false) 43 | expect(received).toEqual(expected) 44 | end) 45 | end) 46 | -------------------------------------------------------------------------------- /src/jest-globals/src/index.lua: -------------------------------------------------------------------------------- 1 | -- ROBLOX upstream: https://github.com/facebook/jest/blob/v28.0.0/packages/jest-globals/src/index.ts 2 | -- /** 3 | -- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 4 | -- * 5 | -- * This source code is licensed under the MIT license found in the 6 | -- * LICENSE file in the root directory of this source tree. 7 | -- * 8 | -- */ 9 | 10 | local Packages = script.Parent.Parent 11 | local LuauPolyfill = require(Packages.LuauPolyfill) 12 | local Error = LuauPolyfill.Error 13 | 14 | local JestEnvironment = require(Packages.JestEnvironment) 15 | type Jest = JestEnvironment.Jest 16 | local importedExpect = require(Packages.Expect) 17 | 18 | -- ROBLOX deviation START: additional imports 19 | local jestTypesModule = require(Packages.JestTypes) 20 | type TestFrameworkGlobals = jestTypesModule.Global_TestFrameworkGlobals 21 | 22 | local ExpectModule = require(Packages.Expect) 23 | type MatcherState = ExpectModule.MatcherState 24 | type ExpectExtended = ExpectModule.ExpectExtended 25 | -- ROBLOX deviation END 26 | 27 | type JestGlobals = 28 | { 29 | jest: Jest, 30 | expect: typeof(importedExpect), 31 | expectExtended: ExpectExtended<{ [string]: (...any) -> nil }>, 32 | } 33 | -- ROBLOX deviation START: using TestFrameworkGlobals instead of declaring variables one by one 34 | & TestFrameworkGlobals 35 | -- ROBLOX deviation END 36 | 37 | error(Error.new( 38 | -- ROBLOX deviation START: aligned message to make sense for jest-roblox 39 | "Do not import `JestGlobals` outside of the Jest 3 test environment.\n" 40 | .. "Tip: Jest 2 uses a different pattern - check your Jest version." 41 | -- ROBLOX deviation END 42 | )) 43 | 44 | return ({} :: any) :: JestGlobals 45 | -------------------------------------------------------------------------------- /src/jest-util/src/__tests__/clearLine.roblox.spec.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | * Copyright (c) Roblox Corporation. All rights reserved. 3 | * Licensed under the MIT License (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * https://opensource.org/licenses/MIT 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | ]] 15 | 16 | local CurrentModule = script.Parent 17 | local SrcModule = CurrentModule.Parent 18 | local Packages = SrcModule.Parent 19 | 20 | local JestGlobals = require(Packages.Dev.JestGlobals) 21 | local jest = JestGlobals.jest 22 | local expect = JestGlobals.expect 23 | local describe = JestGlobals.describe 24 | local it = JestGlobals.it 25 | local beforeEach = JestGlobals.beforeEach 26 | 27 | local clearLine = require(SrcModule.clearLine).default 28 | 29 | describe("clearLine", function() 30 | local writeMock 31 | local stream 32 | beforeEach(function() 33 | writeMock = jest.fn() 34 | stream = { 35 | write = writeMock, 36 | } 37 | end) 38 | 39 | it("should NOT clear line if stream is NOT TTY", function() 40 | clearLine(stream) 41 | 42 | expect(writeMock).never.toHaveBeenCalled() 43 | end) 44 | 45 | it("should clear line if stream is TTY", function() 46 | stream.isTTY = true 47 | clearLine(stream) 48 | 49 | expect(writeMock).toHaveBeenCalledTimes(1) 50 | expect(writeMock).toHaveBeenCalledWith(stream, "\x1b[999D\x1b[K") 51 | end) 52 | end) 53 | --------------------------------------------------------------------------------