fdir icon indicating copy to clipboard operation
fdir copied to clipboard

Migrate away from mock-fs

Open thecodrr opened this issue 4 months ago • 1 comments

We were using mock-fs for testing symlinks and some other things. Unfortunately, mock-fs does not support opendir API which will be used by the iterator API we plan on adding in the future. This PR migrates the symlink and other mock-fs dependent tests to use the actual filesystem instead. This has a number of advantages:

  • mock-fs is no longer maintained and will probably be phased out as soon as Node.js removes support for bindings
  • mock-fs does not always accurately represent how an actual filesystem works.

Since this PR changes how tests work, it should be tested on some real world cases as well.

cc @SuperchupuDev (would love if you can test this out with tinyglobby)

thecodrr avatar Aug 16 '25 13:08 thecodrr

thanks for pinging me, this pr makes 9 tinyglobby tests fail:

test at test/index.test.ts:76:1
✖ negative patterns setting root as / (2.92105ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
  + []
  - [
  -   'a/a.txt',
  -   'b/a.txt'
  - ]
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:78:10)
      at async Test.run (node:internal/test_runner/test:1088:7)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [],
    expected: [ 'a/a.txt', 'b/a.txt' ],
    operator: 'deepStrictEqual'
  }

test at test/index.test.ts:157:1
✖ debug option (10.681461ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
  
  16 !== 11
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:162:10)
      at async Test.run (node:internal/test_runner/test:1088:7)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: 16,
    expected: 11,
    operator: 'strictEqual'
  }

test at test/index.test.ts:167:1
✖ debug option from process.env (1.422483ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
  
  16 !== 11
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:173:10)
      at async Test.run (node:internal/test_runner/test:1088:7)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: 16,
    expected: 11,
    operator: 'strictEqual'
  }

test at test/index.test.ts:210:1
✖ fully handle absolute patterns (0.533418ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
  + []
  - [
  -   '../b/a.txt',
  -   'a.txt'
  - ]
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:212:10)
      at async Test.run (node:internal/test_runner/test:1088:7)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [],
    expected: [ '../b/a.txt', 'a.txt' ],
    operator: 'deepStrictEqual'
  }

test at test/index.test.ts:220:1
✖ leading ../ (0.519443ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
  + []
  - [
  -   '../b/a.txt',
  -   '../b/b.txt'
  - ]
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:222:10)
      at async Test.run (node:internal/test_runner/test:1088:7)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [],
    expected: [ '../b/a.txt', '../b/b.txt' ],
    operator: 'deepStrictEqual'
  }

test at test/index.test.ts:225:1
✖ leading ../ with only dirs (0.670456ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
  + []
  - [
  -   '../.a/a/'
  - ]
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:227:10)
      at async Test.run (node:internal/test_runner/test:1088:7)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [],
    expected: [ '../.a/a/' ],
    operator: 'deepStrictEqual'
  }

test at test/index.test.ts:230:1
✖ leading ../ plus normal pattern (0.458028ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
  + []
  - [
  -   '../b/a.txt',
  -   '../b/b.txt',
  -   'a.txt'
  - ]
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:232:10)
      at async Test.run (node:internal/test_runner/test:1088:7)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [],
    expected: [ '../b/a.txt', '../b/b.txt', 'a.txt' ],
    operator: 'deepStrictEqual'
  }

test at test/index.test.ts:279:1
✖ deep with ../ (0.466744ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
  + []
  - [
  -   '../.deep/a/a/a.txt',
  -   'a.txt'
  - ]
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:281:10)
      at async Test.run (node:internal/test_runner/test:1088:7)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [],
    expected: [ '../.deep/a/a/a.txt', 'a.txt' ],
    operator: 'deepStrictEqual'
  }

test at test/index.test.ts:501:1
✖ relative self that points to . (0.296445ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
  + actual - expected
  
  + []
  - [
  -   '.'
  - ]
  
      at TestContext.<anonymous> (file:///home/meow/code/tinyglobby/test/index.test.ts:503:10)
      at Test.runInAsyncScope (node:async_hooks:214:14)
      at Test.run (node:internal/test_runner/test:1081:25)
      at Test.processPendingSubtests (node:internal/test_runner/test:763:18)
      at Test.postRun (node:internal/test_runner/test:1210:19)
      at Test.run (node:internal/test_runner/test:1138:12)
      at async Test.processPendingSubtests (node:internal/test_runner/test:763:7) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: [],
    expected: [ '.' ],
    operator: 'deepStrictEqual'
  }

SuperchupuDev avatar Aug 17 '25 00:08 SuperchupuDev