From e2c10beb770edb8cdcf5c88a638633f0931973fe Mon Sep 17 00:00:00 2001 From: Jon Ursenbach <jon@ursenba.ch> Date: Tue, 11 Jan 2022 14:31:02 -0800 Subject: [PATCH] fix: pulling some snapshots that have color in them as they're causing flaky tests --- .../cmds/__snapshots__/login.test.js.snap | 5 ---- .../cmds/__snapshots__/versions.test.js.snap | 23 ------------------- __tests__/cmds/login.test.js | 10 ++++++-- __tests__/cmds/versions.test.js | 8 +++++-- __tests__/set-node-env.js | 3 --- 5 files changed, 14 insertions(+), 35 deletions(-) delete mode 100644 __tests__/cmds/__snapshots__/login.test.js.snap delete mode 100644 __tests__/cmds/__snapshots__/versions.test.js.snap diff --git a/__tests__/cmds/__snapshots__/login.test.js.snap b/__tests__/cmds/__snapshots__/login.test.js.snap deleted file mode 100644 index e39ee3c50..000000000 --- a/__tests__/cmds/__snapshots__/login.test.js.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`rdme login should post to /login on the API 1`] = `"Successfully logged in as user@example.com to the subdomain project."`; - -exports[`rdme login should send 2fa token if provided 1`] = `"Successfully logged in as user@example.com to the subdomain project."`; diff --git a/__tests__/cmds/__snapshots__/versions.test.js.snap b/__tests__/cmds/__snapshots__/versions.test.js.snap deleted file mode 100644 index afb45d79e..000000000 --- a/__tests__/cmds/__snapshots__/versions.test.js.snap +++ /dev/null @@ -1,23 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`rdme versions* rdme versions should get a specific version object if version flag provided 1`] = ` -"Version: 1.0.0 -Codename: None -Created on: 2019-06-17T22:39:56.462Z -Released on: undefined -[90m┌───────────────┬───────────┬─────────┬───────────┐[39m -[90m│[39m[31m Is deprecated [39m[90m│[39m[31m Is hidden [39m[90m│[39m[31m Is beta [39m[90m│[39m[31m Is stable [39m[90m│[39m -[90m├───────────────┼───────────┼─────────┼───────────┤[39m -[90m│[39m no [90m│[39m no [90m│[39m no [90m│[39m yes [90m│[39m -[90m└───────────────┴───────────┴─────────┴───────────┘[39m" -`; - -exports[`rdme versions* rdme versions should make a request to get a list of existing versions 1`] = ` -"[90m┌─────────┬──────────┬───────────────┬───────────┬─────────┬───────────┬──────────────────────────┐[39m -[90m│[39m[31m Version [39m[90m│[39m[31m Codename [39m[90m│[39m[31m Is deprecated [39m[90m│[39m[31m Is hidden [39m[90m│[39m[31m Is beta [39m[90m│[39m[31m Is stable [39m[90m│[39m[31m Created on [39m[90m│[39m -[90m├─────────┼──────────┼───────────────┼───────────┼─────────┼───────────┼──────────────────────────┤[39m -[90m│[39m 1.0.0 [90m│[39m None [90m│[39m no [90m│[39m no [90m│[39m no [90m│[39m yes [90m│[39m 2019-06-17T22:39:56.462Z [90m│[39m -[90m├─────────┼──────────┼───────────────┼───────────┼─────────┼───────────┼──────────────────────────┤[39m -[90m│[39m 2.0.0 [90m│[39m None [90m│[39m no [90m│[39m no [90m│[39m no [90m│[39m yes [90m│[39m 2019-06-17T22:39:56.462Z [90m│[39m -[90m└─────────┴──────────┴───────────────┴───────────┴─────────┴───────────┴──────────────────────────┘[39m" -`; diff --git a/__tests__/cmds/login.test.js b/__tests__/cmds/login.test.js index 8a66da270..2274787bc 100644 --- a/__tests__/cmds/login.test.js +++ b/__tests__/cmds/login.test.js @@ -34,7 +34,10 @@ describe('rdme login', () => { const mock = nock(config.get('host')).post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); - await expect(cmd.run({ email, password, project })).resolves.toMatchSnapshot(); + const output = await cmd.run({ email, password, project }); + expect(output).toContain('user@example.com'); + expect(output).toContain('subdomain'); + mock.done(); expect(configStore.get('apiKey')).toBe(apiKey); @@ -78,7 +81,10 @@ describe('rdme login', () => { .post('/api/v1/login', { email, password, project, token }) .reply(200, { apiKey: '123' }); - await expect(cmd.run({ email, password, project, token })).resolves.toMatchSnapshot(); + const output = await cmd.run({ email, password, project, token }); + expect(output).toContain('user@example.com'); + expect(output).toContain('subdomain'); + mock.done(); }); diff --git a/__tests__/cmds/versions.test.js b/__tests__/cmds/versions.test.js index edd32bafa..f6100855f 100644 --- a/__tests__/cmds/versions.test.js +++ b/__tests__/cmds/versions.test.js @@ -54,7 +54,9 @@ describe('rdme versions*', () => { .basicAuth({ user: key }) .reply(200, [versionPayload, version2Payload]); - await expect(versions.run({ key })).resolves.toMatchSnapshot(); + const table = await versions.run({ key }); + expect(table).toContain(version); + expect(table).toContain(version2); mockRequest.done(); }); @@ -75,7 +77,9 @@ describe('rdme versions*', () => { .basicAuth({ user: key }) .reply(200, versionPayload); - await expect(versions.run({ key, version })).resolves.toMatchSnapshot(); + const table = await versions.run({ key, version }); + expect(table).toContain(version); + expect(table).not.toContain(version2); mockRequest.done(); }); diff --git a/__tests__/set-node-env.js b/__tests__/set-node-env.js index aa0d807e1..4bee43cae 100644 --- a/__tests__/set-node-env.js +++ b/__tests__/set-node-env.js @@ -1,4 +1 @@ -// Chalk has trouble with Jest sometimes in test snapshots so we're disabling colorization here for all tests. -process.env.FORCE_COLOR = 0; - process.env.NODE_ENV = 'testing';