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

Add mock API #698

Closed
wants to merge 22 commits into from
Closed

Add mock API #698

wants to merge 22 commits into from

Commits on Oct 15, 2020

  1. Initial tap.mock implementation

    Building from the work started by @nlf
    
    ref: https://gist.github.com/nlf/52ca6adab49e5b3939ba37c7f0fc51c6
    
    Co-authored-by: nlf <quitlahok@gmail.com>
    ruyadorno and nlf committed Oct 15, 2020
    Configuration menu
    Copy the full SHA
    8e19ff2 View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2020

  1. initial lib/mock.js refactor

    - Added param checks and throws TypeErrors on unexpected usage
    - Simplified a bit some of the logic aroung builtin modules cache
    - Fixed some errors introduced while porting the original work from @nlf
    ruyadorno committed Oct 16, 2020
    Configuration menu
    Copy the full SHA
    2a08514 View commit details
    Browse the repository at this point in the history
  2. add t.mock()

    ruyadorno committed Oct 16, 2020
    Configuration menu
    Copy the full SHA
    6b2570e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c27ebea View commit details
    Browse the repository at this point in the history
  4. add docs for the mock API

    ruyadorno committed Oct 16, 2020
    Configuration menu
    Copy the full SHA
    55280ee View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2020

  1. Configuration menu
    Copy the full SHA
    7292ed4 View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2020

  1. better mocks resolution algo

    The mock keys should now be paths relative to the current script/tests
    that is defining it.
    ruyadorno committed Oct 26, 2020
    Configuration menu
    Copy the full SHA
    fff5b70 View commit details
    Browse the repository at this point in the history
  2. docs cleanup

    ruyadorno committed Oct 26, 2020
    Configuration menu
    Copy the full SHA
    d7e3007 View commit details
    Browse the repository at this point in the history

Commits on Nov 12, 2020

  1. Support immediately require calls

    Add support to modules that instant executing a required module.
    
        require('./something')()
    
    This mock-fn-as-callback-style was used in test found in npm/cli:
    
        t.test('mock as callback style', t => {
          t.mock('../my-module.js', {
            '../sub-module.js': arg => {
              t.equal(arg, 'expected')
              t.end()
            }
          })
        })
    
    Also added more varied situations to stress test the module replacement,
    such as using t.mock within one of the defined mocks, require calls at
    execution time along with tests for the mock as callback style.
    ruyadorno committed Nov 12, 2020
    Configuration menu
    Copy the full SHA
    51f45f5 View commit details
    Browse the repository at this point in the history

Commits on Dec 10, 2020

  1. docs cleanup

    ruyadorno committed Dec 10, 2020
    Configuration menu
    Copy the full SHA
    1857c5f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5c43286 View commit details
    Browse the repository at this point in the history

Commits on Dec 11, 2020

  1. Configuration menu
    Copy the full SHA
    513586b View commit details
    Browse the repository at this point in the history
  2. support no defined mocks

    ruyadorno committed Dec 11, 2020
    Configuration menu
    Copy the full SHA
    edee953 View commit details
    Browse the repository at this point in the history
  3. add cache system

    ruyadorno committed Dec 11, 2020
    Configuration menu
    Copy the full SHA
    3745cb2 View commit details
    Browse the repository at this point in the history

Commits on Dec 17, 2020

  1. caching is a terrible idea

    ruyadorno committed Dec 17, 2020
    Configuration menu
    Copy the full SHA
    c196db8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e0cdfa7 View commit details
    Browse the repository at this point in the history
  3. fix falsy module mock

    ruyadorno committed Dec 17, 2020
    Configuration menu
    Copy the full SHA
    7f6245c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5980b7b View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6b040a9 View commit details
    Browse the repository at this point in the history
  6. fix cicle required modules

    ruyadorno committed Dec 17, 2020
    Configuration menu
    Copy the full SHA
    8af0892 View commit details
    Browse the repository at this point in the history
  7. better mock obj validation

    ruyadorno committed Dec 17, 2020
    Configuration menu
    Copy the full SHA
    6c5cb81 View commit details
    Browse the repository at this point in the history

Commits on Dec 18, 2020

  1. Configuration menu
    Copy the full SHA
    a8c0d8d View commit details
    Browse the repository at this point in the history