node-formidable / formidable

The most used, flexible, fast and streaming parser for multipart form data. Supports uploading to serverless environments, AWS S3, Azure, GCP or the filesystem. Used in production.
MIT License
7.01k stars 680 forks source link

Try tests again #763

Closed GrosSacASac closed 2 years ago

GrosSacASac commented 2 years ago

3 issues remain:

 FAIL  test/unit/persistent-file.test.js
  ● Test suite failed to run

    persistent-file.test.js: The module 
factory of `jest.mock()` is not allowed to reference any out-of-scope variables.      
    Invalid variable access: jest

      15 |
      16 | jest.mock('fs', () => {
    > 17 |   const fs = jest.requireActual('fs');
         |              ^^^^
      18 |   return {
      19 |     ...fs,
      20 |     unlink: jest.fn(),

and 2 other issues in fixtures, that I also don't understand

jimmywarting commented 2 years ago

Now i'm getting

 FAIL  test/unit/persistent-file.test.js
  ● Test suite failed to run

    ReferenceError: formidable/test/unit/persistent-file.test.js: The module factory of `jest.mock()` is not allowed to reference any out-of-scope variables.
    Invalid variable access: jest
    Allowed objects: AbortController, AbortSignal, AggregateError, Array, ArrayBuffer, Atomics, BigInt, BigInt64Array, BigUint64Array, Boolean, Buffer, DataView, Date, Error, EvalError, Event, EventTarget, FinalizationRegistry, Float32Array, Float64Array, Function, Generator, GeneratorFunction, Infinity, Int16Array, Int32Array, Int8Array, InternalError, Intl, JSON, Map, Math, MessageChannel, MessageEvent, MessagePort, NaN, Number, Object, Promise, Proxy, RangeError, ReferenceError, Reflect, RegExp, Set, SharedArrayBuffer, String, Symbol, SyntaxError, TextDecoder, TextEncoder, TypeError, URIError, URL, URLSearchParams, Uint16Array, Uint32Array, Uint8Array, Uint8ClampedArray, WeakMap, WeakRef, WeakSet, WebAssembly, __dirname, __filename, arguments, atob, btoa, clearImmediate, clearInterval, clearTimeout, console, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent, escape, eval, expect, exports, global, globalThis, isFinite, isNaN, jest, module, parseFloat, parseInt, performance, process, queueMicrotask, require, setImmediate, setInterval, setTimeout, undefined, unescape.
    Note: This is a precaution to guard against uninitialized mock variables. If it is ensured that the mock is required lazily, variable names prefixed with `mock` (case insensitive) are permitted.

      15 |
      16 | jest.mock('fs', () => {
    > 17 |   const fs = jest.requireActual('fs');
         |              ^^^^
      18 |   return {
      19 |     ...fs,
      20 |     unlink: jest.fn(),

      at File.buildCodeFrameError (node_modules/@babel/core/lib/transformation/file/file.js:248:12)
      at NodePath.buildCodeFrameError (node_modules/@babel/traverse/lib/path/index.js:144:21)
      at newFn (node_modules/@babel/traverse/lib/visitors.js:179:21)
      at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:55:20)
      at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:42:17)
      at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:90:31)
      at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:112:16)

and

 FAIL  test/integration/fixtures.test.js (6.42 s)
  ✕ fixtures (5004 ms)

  ● fixtures

    thrown: "Exceeded timeout of 5000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      30 | };
      31 |
    > 32 | test('fixtures', (done) => {
         | ^
      33 |   const server = createServer();
      34 |   server.listen(PORT, findFixtures);
      35 |

      at test/integration/fixtures.test.js:32:1
GrosSacASac commented 2 years ago

Yes the timeout is because 2 tests inside fail (todo) and the way it was written does not end close the tests .

jest mocking fs I have no idea how to fix it maybe open an issue in jest github to ask