#Pešo1
1 messages · Page 1 of 1 (latest)
hello! please redact your secret key if you share any code
it('Create new customer', async () => {
const customerNewData =
'name=Mail&email=mail@gmail.com&metadata[customerCode]=100200';
const createCustomerRequest = await axios({
method: 'POST',
baseURL: http://localhost:12111/v1/customers,
headers: {
'Content-Type': application/x-www-form-urlencoded,
Authorization: Bearer ${process.env.STRIPE_SECRET_KEY as string},
},
data: customerNewData,
});
const createCustomerResponse = createCustomerRequest.data;
const expectedCustomerResponse = {
address: null,
balance: expect.any(Number),
created: expect.any(Number),
currency: expect.any(String),
default_source: null,
description: null,
discount: null,
email: expect.any(String),
id: expect.any(String),
invoice_prefix: expect.any(String),
invoice_settings: {
custom_fields: null,
default_payment_method: null,
footer: null,
rendering_options: null,
},
livemode: false,
metadata: {},
name: expect.any(String),
next_invoice_sequence: expect.any(Number),
object: expect.any(String),
phone: null,
preferred_locales: [],
shipping: null,
tax_exempt: expect.any(String),
test_clock: null,
};
expect(createCustomerResponse).toBeObject();
expect(createCustomerResponse).toMatchObject(expectedCustomerResponse);
looking at the github issue that you linked, there isn't any issue to be fixed. As the reply mentions :
the responses that you get from stripe-mock don't have much to do with the requests that you sent in: it does request validation, and as long as a request looks okay, it responds with a bundled fixture for the appropriate resource.
what this means is that the response won't include the same data that you pass in