Skip to content

Commit

Permalink
chore(testbed): jest 29, flakiness fixes (#610)
Browse files Browse the repository at this point in the history
* chore(deps-dev): bump jest to v29

* chore: this doesn't appear to work either

* chore: this doesn't appear to work either

docs: https://kulshekhar.github.io/ts-jest/docs/getting-started/options/tsconfig#path-to-a-tsconfig-file

* chore: neither does this

this is probably a typo in the docs but this is what I see in every example: https://kulshekhar.github.io/ts-jest/docs/getting-started/options/tsconfig#path-to-a-tsconfig-file

* chore: what about inline options?

docs: https://kulshekhar.github.io/ts-jest/docs/getting-started/options/tsconfig#inline-compiler-options

* chore(deps-dev): bump jest and ts-jest

* fix: attempt at getting jest config right

* fix: update snapshots

* fix: attempt at making tests less flaky

* chore: remove 'testing' env and use standard 'test'

also rename setup file accordingly

* chore: oops rename config file

* chore: explanatory comments

* chore(deps-dev): bump @types/jest

* chore(deps-dev): bump jest again
  • Loading branch information
kanadgupta authored Oct 5, 2022
1 parent 2918c48 commit 8d0af81
Show file tree
Hide file tree
Showing 13 changed files with 1,285 additions and 1,366 deletions.
346 changes: 173 additions & 173 deletions __tests__/cmds/openapi/__snapshots__/index.test.ts.snap

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions __tests__/cmds/openapi/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,12 @@ describe('rdme openapi', () => {

await expect(openapi.run({ spec, key, version, raw: true })).resolves.toMatchInlineSnapshot(`
"{
\\"commandType\\": \\"create\\",
\\"docs\\": \\"https://dash.readme.com/project/example-project/1.0.1/refs/ex\\",
\\"id\\": 1,
\\"specPath\\": \\"./__tests__/__fixtures__/ref-oas/petstore.json\\",
\\"specType\\": \\"OpenAPI\\",
\\"version\\": \\"1.0.0\\"
"commandType": "create",
"docs": "https://dash.readme.com/project/example-project/1.0.1/refs/ex",
"id": 1,
"specPath": "./__tests__/__fixtures__/ref-oas/petstore.json",
"specType": "OpenAPI",
"version": "1.0.0"
}"
`);

Expand Down
80 changes: 40 additions & 40 deletions __tests__/lib/__snapshots__/commands.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`utils #listByCategory should list commands by category 1`] = `
Object {
"admin": Object {
"commands": Array [
Object {
{
"admin": {
"commands": [
{
"description": "Login to a ReadMe project.",
"hidden": false,
"name": "login",
"position": 1,
},
Object {
{
"description": "Logs the currently authenticated user out of ReadMe.",
"hidden": false,
"name": "logout",
"position": 2,
},
Object {
{
"description": "Displays the current user and project authenticated with ReadMe.",
"hidden": false,
"name": "whoami",
Expand All @@ -25,33 +25,33 @@ Object {
],
"description": "Administration",
},
"apis": Object {
"commands": Array [
Object {
"apis": {
"commands": [
{
"description": "Upload, or resync, your OpenAPI/Swagger definition to ReadMe.",
"hidden": false,
"name": "openapi",
"position": 1,
},
Object {
{
"description": "Reduce an OpenAPI definition into a smaller subset.",
"hidden": false,
"name": "openapi:reduce",
"position": 2,
},
Object {
{
"description": "Validate your OpenAPI/Swagger definition.",
"hidden": false,
"name": "openapi:validate",
"position": 3,
},
Object {
{
"description": "Alias for \`rdme openapi\`. [deprecated]",
"hidden": true,
"name": "swagger",
"position": 4,
},
Object {
{
"description": "Alias for \`rdme openapi:validate\` [deprecated].",
"hidden": true,
"name": "validate",
Expand All @@ -60,15 +60,15 @@ Object {
],
"description": "Upload OpenAPI/Swagger definitions",
},
"categories": Object {
"commands": Array [
Object {
"categories": {
"commands": [
{
"description": "Get all categories in your ReadMe project.",
"hidden": false,
"name": "categories",
"position": 1,
},
Object {
{
"description": "Create a category with the specified title and guide in your ReadMe project.",
"hidden": false,
"name": "categories:create",
Expand All @@ -77,15 +77,15 @@ Object {
],
"description": "Categories",
},
"changelogs": Object {
"commands": Array [
Object {
"changelogs": {
"commands": [
{
"description": "Sync a folder of Markdown files to your ReadMe project as Changelog posts.",
"hidden": false,
"name": "changelogs",
"position": 1,
},
Object {
{
"description": "Sync a single Markdown file to your ReadMe project as a Changelog post.",
"hidden": false,
"name": "changelogs:single",
Expand All @@ -94,15 +94,15 @@ Object {
],
"description": "Changelog",
},
"custompages": Object {
"commands": Array [
Object {
"custompages": {
"commands": [
{
"description": "Sync a folder of Markdown files to your ReadMe project as Custom Pages.",
"hidden": false,
"name": "custompages",
"position": 1,
},
Object {
{
"description": "Sync a single Markdown file to your ReadMe project as a Custom Page.",
"hidden": false,
"name": "custompages:single",
Expand All @@ -111,21 +111,21 @@ Object {
],
"description": "Custom Pages",
},
"docs": Object {
"commands": Array [
Object {
"docs": {
"commands": [
{
"description": "Sync a folder of Markdown files to your ReadMe project.",
"hidden": false,
"name": "docs",
"position": 1,
},
Object {
{
"description": "Edit a single file from your ReadMe project without saving locally.",
"hidden": false,
"name": "docs:edit",
"position": 2,
},
Object {
{
"description": "Sync a single Markdown file to your ReadMe project.",
"hidden": false,
"name": "docs:single",
Expand All @@ -134,15 +134,15 @@ Object {
],
"description": "Documentation",
},
"utilities": Object {
"commands": Array [
Object {
"utilities": {
"commands": [
{
"description": "Helpful OpenAPI generation tooling. [inactive]",
"hidden": true,
"name": "oas",
"position": 2,
},
Object {
{
"description": "Open your current ReadMe project in the browser.",
"hidden": false,
"name": "open",
Expand All @@ -151,27 +151,27 @@ Object {
],
"description": "Other useful commands",
},
"versions": Object {
"commands": Array [
Object {
"versions": {
"commands": [
{
"description": "List versions available in your project or get a version by SemVer (https://semver.org/).",
"hidden": false,
"name": "versions",
"position": 1,
},
Object {
{
"description": "Create a new version for your project.",
"hidden": false,
"name": "versions:create",
"position": 2,
},
Object {
{
"description": "Delete a version associated with your ReadMe project.",
"hidden": false,
"name": "versions:delete",
"position": 4,
},
Object {
{
"description": "Update an existing version for your project.",
"hidden": false,
"name": "versions:update",
Expand Down
2 changes: 0 additions & 2 deletions __tests__/set-node-env.js → __tests__/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
// colorization here for all tests.
// https://github.com/chalk/supports-color/issues/106
process.env.FORCE_COLOR = 0;

process.env.NODE_ENV = 'testing';
File renamed without changes.
28 changes: 19 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */

module.exports = {
coveragePathIgnorePatterns: ['/dist', '/node_modules'],
coverageThreshold: {
Expand All @@ -8,23 +10,31 @@ module.exports = {
statements: 90,
},
},
globals: {
'ts-jest': {
tsconfig: '__tests__/tsconfig.json',
},
},
modulePaths: ['<rootDir>'],
modulePathIgnorePatterns: ['<rootDir>/dist/'],
preset: 'ts-jest/presets/js-with-ts',
/**
* Not sure why, but the non-legacy preset gives us TS compilation errors
* since it's not properly reading our testing TS config.
* @see {@link https://kulshekhar.github.io/ts-jest/docs/getting-started/presets}
* @see {@link https://kulshekhar.github.io/ts-jest/docs/getting-started/options/tsconfig/}
*/
preset: 'ts-jest/presets/js-with-ts-legacy',
roots: ['<rootDir>'],
setupFiles: ['./__tests__/set-node-env'],
setupFiles: ['./__tests__/setup'],
setupFilesAfterEnv: ['jest-extended/all'],
testPathIgnorePatterns: [
'<rootDir>/dist/',
'<rootDir>/__tests__/helpers/',
'<rootDir>/__tests__/get-api-nock',
'<rootDir>/__tests__/set-node-env',
'<rootDir>/__tests__/setup',
],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(js?|ts?)$',
transform: {},
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '__tests__/tsconfig.json',
},
],
},
};
Loading

0 comments on commit 8d0af81

Please sign in to comment.