Giter VIP home page Giter VIP logo

ember-cli-pact's People

Contributors

dependabot[bot] avatar dfreeman avatar ember-tomster avatar jamescdavis avatar joaogfarias avatar joshbranham avatar psbanka avatar sglanzer avatar tomasbasham avatar twokul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-cli-pact's Issues

Node-side testing

Minimally, unit test coverage request dispatching and pact verification

Error using RestSerializer

Hi @dfreeman,

So as I mentioned in Slack yesterday, my team and I are trying to integrate ember-cli-pact with our repo, which uses a RestSerializer, and have come across the error "`Invalid attempt to destructure non-iterable instance."

After downloading your repo and ensuring all tests were passing, I was then able to reproduce the error in your repo by changing the mirage application.js file to the following:

import { RestSerializer } from 'ember-cli-mirage';
import { PactEnabled } from 'ember-cli-pact/mock-provider/mirage';

export default class ApplicationSerializer extends PactEnabled(RestSerializer) {

}

If you're able to offer any insight that would be awesome. Thanks in advance!

Pact JS

Hi there,

I'm evaluating ember-cli-pact for the organisation I work for. I've previously worked with:

https://github.com/pact-foundation/pact-js

These guys are based in Melbourne but I was wondering if you had come across them? And perhaps more importantly for us, if you had plans to integrate some of their work into ember-cli-pact? Would also be keen to hear what your plans are for ember-cli-pact - is it just a proof of concept or will you be extending and enhancing it?

Sorry, not so much of an 'issue' but would be keen to hear more.

Fraser

Migrate `addon/` to `addon-test-support/`.

The addon-test-support/ tree automatically gets added to the test-support.js asset (as opposed to vendor.js). By default, these assets are transpiled to <addon-name>/test-support, but you can easily modify that to remove the /test-support suffix if the addon is "test only" (see ember-test-helpers for an example).

Add `setupTest` style export for usage with [email protected]

The following should be supportable when the host app has [email protected] or higher:

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { setupPact } from 'ember-cli-pact';

module('stuff', function(hooks) {
  setupTest(hooks);
  setupPact(hooks, {
    provider: 'my-api',
    consumer: 'my-app'
  });

  test('locating a person by ID', async function(assert) {
    this.given('a person exists', { id: '123', name: 'Alice' });

    let person = await this.interaction(() => this.store().findRecord('person', '123'));

    assert.equal(person.get('id'), '123');
    assert.equal(person.get('name'), 'Alice');
  });
});

I believe that this change should reduce fairly significantly the amount of custom glue code that is present today...

Runtime testing

Need coverage for:

  • provider state management
  • explicit interaction config
  • captured request/response cycles
  • Mirage integration
  • QUnit and Mocha integration

Can we get a new release out

Hi, @dfreeman โ€“ I'm hoping we can get a new release of Ember-cli-pact out. The last release was on October 19th, and the last PR I submitted was on the 22nd of October. I've been running builds against my own github fork since then but would prefer to be building against mainline ember-pact-cli if possible? Thanks! ๐Ÿ˜„

Cannot create a DELETE request

Hi,

We are trying to create a delete request using ember-pact-cli and mirage using the following steps:
`
let model = server.create('model', {
name: 'some model'
});

given('a model item exists', model);

let actualModel = await this.store().findRecord('model', 1);

actualModel.deleteRecord();

await interaction(function() {
actualModel.save();
});`

OR

`
let model = server.create('model', {
name: 'some model'
});

given('a model item exists', model);

let actualModel = await this.store().findRecord('model', 1);

await interaction(function() {
actualModel.destroyRecord();
});`

Everytime I run the ember tests to generate the pact file, I am getting the following error:
cannot read property 'method' of null

I've cloned this repo and added a delete test on the examples here and the same error is being thrown as well.

I was wondering if this is the correct way of creating a DELETE request or wether this could be a bug or not.

Thanks in advance.

resource.modelName is dasherized improperly

Hello, sorry if this is a user-error question, but I cannot seem to figure out why it is that I have camelized model-names, but when doing pact-testing, I am getting errors because pact/mirage is searching for dasherized names.

My test looks like this:

module('Pact | certificates', function(hooks) {
  setupTest(hooks)
  setupPact(hooks, { provider: 'my-api', consumer: 'my-app' })

  test('tls/certificates endpoint', async function(assert) {
    given('the customer exists')
    given('a generic certificate exists')
    const query = {filter: {'customer.id': '123456'}}
    const tlsCertificates = await interaction(() => this.store().query('tls-certificate', query))
    assert.equal(tlsCertificates[0].get('id'), '123456')
  })
})

However, in mock-provider/mirage.js, ember-cli-pact is looking for this.schema.modelFor(resource.modelName). Unfortunately, the resource.modelName value is dasherized here (i.e. tls-certificate), and all of the models in the schema are camelcased (i.e. tlsCertificate).

Using camelized model names in the test does not have any affect, and all production code uses this.store.query('tls-certificate') just fine. Does anyone have any thoughts as to how I can get ember-cli-pact to cooperate with my camelized models or how to change all my models within mirage to be dasherized if that's the only way to go?

Configuration

We need a bunch of contextual information that should probably be defaulted in environment.js and overridable on a per-module basis:

  • consumer name (effectively constant, since the project is the consumer)
  • provider name (may be constant, may vary widely from test to test)
  • where to look for provider state definitions
  • what mock provider to use (Mirage out of the box, but would be totally reasonable to support raw Pretender or pact-web)
  • where to persist pact files

Matching rule for all elements

Hi,

I don't really understand how to configure the matching rules to check all the items of an array.

Let's say for example that we are fetching a list of articles, each with a title. How can we configure it to have a resulting $.data[*].attributes.title ?

According to the doc I may use arrayElements(matcher) but I don't find out how to ๐Ÿ˜Š . I tried :

    specifyMatchingRules({
      response: {
        body: {
          data: {
            attributes: {
              title: arrayElements[type()],
            }
          }
        }
      }
    })

Upload and process pacts for persisting

What is the default behavior? Persist or verify?

There's some interesting work to be done in terms of combining:

  • observed request/response data
  • generated match rules from the provider (e.g. from Mirage model metadata)
  • explicit request/response expectations provided with the interaction

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.