Skip to content

Commit

Permalink
build: remove mock-fs as its broken in gituhub actions (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck authored Oct 12, 2023
1 parent 65d4bcf commit 670b83c
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
- name: Install packages
run: npm install

- name: Lint, Compile, Test
run: npm run compile && npm run test -- --coverage --verbose --maxWorkers=2
- name: Compile, Test
run: npm run compile && npm run test -- --coverage --verbose --maxWorkers=1

- name: Run codecov
uses: codecov/codecov-action@v3
Expand Down
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,36 @@
]
},
"devDependencies": {
"@babel/core": "7.22.5",
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
"@babel/plugin-transform-typescript": "7.22.5",
"@babel/preset-env": "7.22.5",
"@babel/preset-typescript": "7.22.5",
"@babel/types": "^7.22.5",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
"@typescript-eslint/eslint-plugin": "5.60.0",
"@typescript-eslint/parser": "5.60.0",
"babel-jest": "29.5.0",
"@babel/core": "7.23.2",
"@babel/plugin-transform-modules-commonjs": "^7.23.0",
"@babel/plugin-transform-typescript": "7.22.15",
"@babel/preset-env": "7.23.2",
"@babel/preset-typescript": "7.23.2",
"@babel/types": "^7.23.0",
"@types/jest": "^29.5.5",
"@types/node": "^20.8.4",
"@typescript-eslint/eslint-plugin": "6.7.5",
"@typescript-eslint/parser": "6.7.5",
"babel-jest": "29.7.0",
"babel-plugin-module-resolver": "5.0.0",
"eslint": "8.43.0",
"eslint": "8.51.0",
"eslint-config-google": "0.14.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-deprecation": "1.4.1",
"eslint-plugin-jest": "27.2.2",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-deprecation": "2.0.0",
"eslint-plugin-jest": "27.4.2",
"eslint-plugin-jest-extended": "2.0.0",
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-prettier": "5.0.1",
"husky": "^8.0.3",
"is-ci": "3.0.1",
"jest": "^29.5.0",
"lerna": "^7.0.2",
"jest": "^29.7.0",
"lerna": "^7.3.1",
"lerna-changelog": "^2.2.0",
"lint-staged": "13.2.2",
"nock": "^13.3.1",
"prettier": "2.8.8",
"lint-staged": "14.0.1",
"nock": "^13.3.4",
"prettier": "3.0.3",
"prettier-eslint": "15.0.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.1.3"
"typescript": "^5.2.2"
}
}
2 changes: 1 addition & 1 deletion packages/accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@vonage/auth": "^1.6.0",
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/applications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@vonage/vetch": "^1.5.1"
},
"devDependencies": {
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@vonage/vetch": "^1.5.1"
},
"devDependencies": {
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"debug": "^4.3.4"
},
"devDependencies": {
"@types/node": "^20.3.1"
"@types/node": "^20.8.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
6 changes: 3 additions & 3 deletions packages/jwt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
},
"dependencies": {
"debug": "^4.3.4",
"jsonwebtoken": "^9.0.0",
"uuid": "^9.0.0"
"jsonwebtoken": "^9.0.2",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/uuid": "^9.0.2"
"@types/uuid": "^9.0.5"
},
"publishConfig": {
"directory": "dist"
Expand Down
4 changes: 2 additions & 2 deletions packages/meetings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"dependencies": {
"@vonage/server-client": "^1.8.2",
"@vonage/vetch": "^1.5.1",
"fast-xml-parser": "^4.2.5",
"fast-xml-parser": "^4.3.2",
"form-data": "^4.0.0",
"lodash.pick": "^4.4.0"
},
"devDependencies": {
"@amvijay/multipart-parser": "^1.0.2",
"@vonage/auth": "^1.6.0",
"nock": "^13.3.1"
"nock": "^13.3.4"
}
}
2 changes: 1 addition & 1 deletion packages/messages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"debug": "^4.3.4"
},
"devDependencies": {
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/number-insights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@vonage/vetch": "^1.5.1"
},
"devDependencies": {
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/numbers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"lodash.omit": "^4.5.0"
},
"devDependencies": {
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/pricing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@vonage/vetch": "^1.5.1"
},
"devDependencies": {
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
43 changes: 20 additions & 23 deletions packages/proactive-connect/__tests__/proactiveConnect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import nock from 'nock';
import { Auth } from '@vonage/auth';
import { BASE_URL } from './common';
import testDataSets from './__dataSets__/index';
import { readFileSync, existsSync } from 'fs';
import mockFs from 'mock-fs';
import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
import { rm } from 'fs/promises';
import { parse } from '@amvijay/multipart-parser';

const key = readFileSync(`${__dirname}/private.test.key`).toString();

const CSV_DIR = '/tmp';
const CSV_DIR = `${process.cwd()}/path`;

const getResults = async (
generator: boolean,
Expand Down Expand Up @@ -90,9 +90,9 @@ describe.each(testDataSets)('$label', ({ tests }) => {
async ({ request, response, clientMethod, parameters, error }) => {
scope.intercept(...request).reply(...response);

await expect(() =>
client[clientMethod](...parameters),
).rejects.toThrow(error);
await expect(() => client[clientMethod](...parameters)).rejects.toThrow(
error,
);
expect(nock.isDone()).toBeTruthy();
},
);
Expand All @@ -102,13 +102,11 @@ describe('File tests', () => {
let client;
let scope;

beforeEach(function () {
mockFs({
[CSV_DIR]: {},
[`${CSV_DIR}/upload`]: {
'upload-file.csv': `fizz,buzz\nfoo,bar`,
},
});
beforeEach(() => {
if (!existsSync(CSV_DIR)) {
mkdirSync(CSV_DIR);
}
writeFileSync(`${CSV_DIR}/upload-file.csv`, `fizz,buzz\nfoo,bar`);
client = new ProactiveConnect(
new Auth({
privateKey: key,
Expand All @@ -122,11 +120,14 @@ describe('File tests', () => {
}).persist();
});

afterEach(function () {
afterEach(async () => {
client = null;
scope = null;
nock.cleanAll();
mockFs.restore();
await rm(CSV_DIR, {
force: true,
recursive: true,
});
});

test('Can download CSV file', async () => {
Expand All @@ -153,21 +154,17 @@ describe('File tests', () => {
});

test('Can upload CSV File', async () => {
const file = `${CSV_DIR}/upload/upload-file.csv`;
const file = `${CSV_DIR}/upload-file.csv`;
expect(existsSync(file)).toBeTruthy();
const fileBuf = readFileSync(file);
scope
.post(
`/v0.1/bulk/lists/10000000-0000-0000-0000-000000000000/items/download`,
(body) => {
const parts = parse(
Buffer.from(body, 'hex'),
client.FORM_BOUNDARY,
);
const parts = parse(Buffer.from(body, 'hex'), client.FORM_BOUNDARY);
return parts.reduce((acc, part) => {
if (part.name === 'file') {
return (
acc && !!Buffer.compare(parts.content, fileBuf)
);
return acc && !!Buffer.compare(parts.content, fileBuf);
}

return true;
Expand Down
3 changes: 1 addition & 2 deletions packages/proactive-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"devDependencies": {
"@amvijay/multipart-parser": "^1.0.2",
"@vonage/auth": "^1.6.0",
"mock-fs": "^5.2.0",
"nock": "^13.3.1"
"nock": "^13.3.4"
}
}
2 changes: 1 addition & 1 deletion packages/redact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@vonage/auth": "^1.6.0",
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
23 changes: 13 additions & 10 deletions packages/server-client/__tests__/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ import nock from 'nock';
import { FileClient } from '../lib';
import { BASE_URL } from './common';
import { Auth } from '@vonage/auth';
import mockFs from 'mock-fs';
import { readFileSync, existsSync } from 'fs';
import { mkdirSync, readFileSync, existsSync } from 'fs';
import { rm } from 'fs/promises';

const FILE_PATH = '/path';
const FILE_PATH = `${process.cwd()}/path`;

const key = readFileSync(`${__dirname}/private.test.key`).toString();

describe('File tests', () => {
let client;
let scope;

beforeEach(function () {
mockFs({
[FILE_PATH]: {},
});

beforeEach(() => {
if (!existsSync(FILE_PATH)) {
mkdirSync(FILE_PATH);
}
client = new FileClient(
new Auth({
privateKey: key,
Expand All @@ -32,11 +31,15 @@ describe('File tests', () => {
}).persist();
});

afterEach(function () {
afterEach(async () => {
client = null;
scope = null;
nock.cleanAll();
mockFs.restore();

await rm(FILE_PATH, {
force: true,
recursive: true,
});
});

test('Can download file with url', async () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/server-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"lodash.snakecase": "^4.1.1"
},
"devDependencies": {
"mock-fs": "5.2.0",
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/sms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"@vonage/auth": "^1.6.0",
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/subaccounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
},
"devDependencies": {
"@vonage/auth": "^1.6.0",
"nock": "^13.3.1"
"nock": "^13.3.4"
}
}
2 changes: 1 addition & 1 deletion packages/users/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
},
"devDependencies": {
"@vonage/auth": "^1.6.0",
"nock": "^13.3.2"
"nock": "^13.3.4"
}
}
2 changes: 1 addition & 1 deletion packages/verify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"lodash.omit": "^4.5.0"
},
"devDependencies": {
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/verify2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
},
"devDependencies": {
"@vonage/auth": "^1.6.0",
"nock": "^13.3.1"
"nock": "^13.3.4"
}
}
7 changes: 3 additions & 4 deletions packages/vetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
"dependencies": {
"debug": "^4.3.4",
"lodash.merge": "^4.6.2",
"node-fetch": "^2.6"
"node-fetch": "^2.2"
},
"devDependencies": {
"nock": "^13.3.1"
"nock": "^13.3.4"
},
"publishConfig": {
"directory": "dist"
},
"gitHead": "328f18e5c8a458cb4d06d7955ec2399a6ce6f5d8"
}
}
Loading

0 comments on commit 670b83c

Please sign in to comment.