Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check versions when npm.license is missing #53

Closed
wants to merge 9 commits into from

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Mar 22, 2022

Re-create #6

Fixes #5

Original description by @macklinu:

I wanted to contribute a fix for #5, but it looks like I'm not mocking node-fetch properly in the tests, and I believe the danger test snapshot changed to the latest danger README (aka it's fetching data from the network in the tests). If you could help out on this, that'd be awesome. I think this is the general fix desired - open to feedback! 😄

@glensc
Copy link
Contributor Author

glensc commented Mar 22, 2022

Tried to re-create as smaller atomic commits while rebased:

@glensc
Copy link
Contributor Author

glensc commented Mar 22, 2022

Jest doesn't like things here.

➜ ./node_modules/.bin/jest
 FAIL  src/index.test.ts
  ● Test suite failed to run

    /Users/glen/scm/node/danger/danger-plugin-yarn/src/index.test.ts: babel-plugin-jest-hoist: The module factory of `jest.mock()` is not allowed to reference any out-of-scope variables.
    Invalid variable access: fixtureDangerNpmInfo
    Whitelisted objects: Array, ArrayBuffer, Boolean, DataView, Date, Error, EvalError, Float32Array, Float64Array, Function, Generator, GeneratorFunction, Infinity, Int16Array, Int32Array, Int8Array, InternalError, Intl, JSON, Map, Math, NaN, Number, Object, Promise, Proxy, RangeError, ReferenceError, Reflect, RegExp, Set, String, Symbol, SyntaxError, TypeError, URIError, Uint16Array, Uint32Array, Uint8Array, Uint8ClampedArray, WeakMap, WeakSet, arguments, expect, jest, require, undefined, global, clearInterval, clearTimeout, setInterval, setTimeout, queueMicrotask, performance, clearImmediate, setImmediate, structuredClone.
    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` are permitted.

      at invariant (node_modules/babel-plugin-jest-hoist/build/index.js:13:11)
      at newFn (node_modules/babel-traverse/lib/visitors.js:276:21)
      at NodePath._call (node_modules/babel-traverse/lib/path/context.js:76:18)
      at NodePath.call (node_modules/babel-traverse/lib/path/context.js:48:17)
      at NodePath.visit (node_modules/babel-traverse/lib/path/context.js:105:12)
      at TraversalContext.visitQueue (node_modules/babel-traverse/lib/context.js:150:16)
      at TraversalContext.visitMultiple (node_modules/babel-traverse/lib/context.js:103:17)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.388s
Ran all test suites.

@glensc
Copy link
Contributor Author

glensc commented Mar 22, 2022

Now at 58d8b95, some other errors:

➜ ./node_modules/.bin/jest
 FAIL  src/index.test.ts
  ● Test suite failed to run

    /Users/glen/scm/node/danger/danger-plugin-yarn/node_modules/node-fetch/src/index.js:9
    import http from 'node:http';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at new Script (node:vm:100:7)
      at Object.<anonymous> (src/index.ts:13:15)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.304s, estimated 3s
Ran all test suites.

@glensc
Copy link
Contributor Author

glensc commented Mar 22, 2022

I would re-do the fetch mocking (in a separate PR) using this package:

WDYT?

@glensc
Copy link
Contributor Author

glensc commented Oct 21, 2022

Seems the repo owner nor the original PR author are interested of my efforts. What a pity. Closing then.

@glensc glensc closed this Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve license checker
2 participants