Skip to content

Commit

Permalink
test(instrumentation-fs): add failing test for bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubKoralewski committed Dec 17, 2022
1 parent 4098e6a commit 7c4c533
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/node/instrumentation-fs/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const CALLBACK_FUNCTIONS: FMember[] = [
'readFile',
'readlink',
'realpath',
['realpath', 'native'],
'rename',
'rm', // added in v14
'rmdir',
Expand Down Expand Up @@ -111,6 +112,7 @@ export const SYNC_FUNCTIONS: FMember[] = [
'readFileSync',
'readlinkSync',
'realpathSync',
['realpathSync', 'native'],
'renameSync',
'rmdirSync',
'rmSync', // added in v14
Expand Down
19 changes: 19 additions & 0 deletions plugins/node/instrumentation-fs/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import * as sinon from 'sinon';
import type * as FSType from 'fs';
import tests, { TestCase, TestCreator } from './definitions';
import type { FMember, FPMember, CreateHook, EndHook } from '../src/types';
import { SYNC_FUNCTIONS } from '../src/constants';
import * as fsActual from 'fs'

const supportsPromises = parseInt(process.versions.node.split('.')[0], 10) > 8;

Expand Down Expand Up @@ -260,6 +262,23 @@ describe('fs instrumentation', () => {
});
};

describe('Syncronous API native', () => {
beforeEach(() => {
plugin.enable();
});
it('should not remove fs functions', () => {
console.log(fsActual)
for (const fname of SYNC_FUNCTIONS) {
if(Array.isArray(fname)) {
let [K, L] = fname
assert.strictEqual(typeof (fsActual[K] as any)[L], 'function', `fs.${K}.${L} is not a function`);
} else {
assert.strictEqual(typeof fsActual[fname], 'function', `fs.${fname} is not a function`);
}
}
})
})

describe('Syncronous API', () => {
const selection: TestCase[] = tests.filter(
([, , , , options = {}]) => options.sync !== false
Expand Down

0 comments on commit 7c4c533

Please sign in to comment.