Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Last active August 30, 2024 21:07

Revisions

  1. dadamssg revised this gist Aug 30, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion contacts.test.ts
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ test('can view contacts', async ({ page }) => {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({
    // the api i'm interacting with is running on port 6000. This is what i need to mock
    // the api I'm pulling data from is running on port 6000. This is what I need to mock
    url: 'http://localhost:6000/people',
    method: 'post',
    once: true,
  2. dadamssg revised this gist Aug 30, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions contacts.test.ts
    Original file line number Diff line number Diff line change
    @@ -3,10 +3,12 @@ import { login } from './auth'

    test('can view contacts', async ({ page }) => {
    await login({ page })
    // remix is running on port 3000
    await fetch('http://localhost:3000/app/playwright', {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({
    // the api i'm interacting with is running on port 6000. This is what i need to mock
    url: 'http://localhost:6000/people',
    method: 'post',
    once: true,
  3. dadamssg revised this gist Aug 30, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion contacts.test.ts
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ test('can view contacts', async ({ page }) => {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({
    url: 'http://localhost:6000/person/list',
    url: 'http://localhost:6000/people',
    method: 'post',
    once: true,
    response: {
  4. dadamssg revised this gist Aug 30, 2024. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions contacts.test.ts
    Original file line number Diff line number Diff line change
    @@ -16,10 +16,7 @@ test('can view contacts', async ({ page }) => {
    id: 'abc',
    firstname: 'Sally',
    lastname: 'Rogers',
    email1: 'sally@example.com',
    lastupdatedate: '2021-05-13 12:04:05.000',
    companyid: 'def',
    cfd_companyname: 'Acme',
    email: 'sally@example.com',
    },
    ],
    },
  5. dadamssg created this gist Aug 30, 2024.
    31 changes: 31 additions & 0 deletions contacts.test.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    import { expect, test } from '@playwright/test'
    import { login } from './auth'

    test('can view contacts', async ({ page }) => {
    await login({ page })
    await fetch('http://localhost:3000/app/playwright', {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({
    url: 'http://localhost:6000/person/list',
    method: 'post',
    once: true,
    response: {
    data: [
    {
    id: 'abc',
    firstname: 'Sally',
    lastname: 'Rogers',
    email1: 'sally@example.com',
    lastupdatedate: '2021-05-13 12:04:05.000',
    companyid: 'def',
    cfd_companyname: 'Acme',
    },
    ],
    },
    }),
    })
    await page.goto('/app/contacts')
    const name = page.getByText('Sally Rogers')
    await expect(name).toHaveText('Sally Rogers')
    })