Giter Site home page Giter Site logo

michaelthe / puppyjs Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 3.0 3.12 MB

puppeteer + jest + awesome-code = puppyjs

Home Page: https://puppyjs.com

License: MIT License

JavaScript 95.31% Shell 4.69%
testing end2end e2e-testing puppeteer jest mocking api socket

puppyjs's People

Contributors

constantinospas avatar michaelthe avatar pitops avatar stefanoschrs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

puppyjs's Issues

Generate new tests

Create a command so the user can create new tests using CLI.
For example $ puppy new test testname should create a new file testname.pup.js in e2e folder with basic structure like

describe('description', () => {

  let page

  beforeEach(async () => {
    page = await puppy.newPage()
  })

  afterEach(async () => {
    await page.close()
  })

  it('should ', async function () {
     
  })

})

improve colour coding

i believe we should move the colours to a separate file so that we can have a specific colour coding in logs

How to use puppy serve with sockets?

I am looking to run puppyjs in serve mode using sockets.

It seems that the current implementation allows puppy to emit messages, but I don't see how to configure puppyjs to listen for a message (as you can with the http api). Is this possible? If so, are there any examples?

Have more loose control over the method names in puppy.api.js

Right now puppy only support using uppercase methods for each route

example

'/api/user': {
    headers: {
      'Authorization': 'Bearer some-token'
    },
    'PATCH': {
      body: 'hello from a PATCH'
    }
  }

to make puppy more robust it should work even when using 'patCh'

change register data to body

from

await puppy.register({path: '/api/user', method: 'patch', data: 'updated user'})

to

await puppy.register({path: '/api/user', method: 'patch', **body**: 'updated user'})

API headers definition could be simplified

Instead of defining the headers in the puppy.api.js like the following

'/api/users': {
    'GET': {
      headers: [
        {
          key: 'X-Session-ID',
          value: '234905823409578'
        }
      ],
      status: 200,
      body: 'hello its a GET'
    }
}

To this

'/api/users': {
    'GET': {
      headers: [
        {
          'X-Session-ID' :  '234905823409578'
        }
      ],
      status: 200,
      body: 'hello its a GET'
    }
}

Ability to hot reload static directory when changes are made

For example in an Angular app, you would use ng build -w which will create a dist folder and puppy would server index.html. However if you make changes to the angular app, you need to manually reload the page.

For convenience it would be great to have live-reload functionality.

Ability to turn off --inspect flag

Right now the flag is hardcoded for node --inspect. User should have the ability to add it as an argument possibly as a --debug flag.

Rename .e2e.js tests to .pup.js

Instead of having our test files end in .e2e.js we can change that to .pup.js. Aside from "branding", the user might have other tests that end to .e2e.js and run by another tool in the same project.

Another requirement is that the user must be able to define the extension that puppy will recognise to run the tests by defining it in the puppy.config.js file and optionally add an argument to the command for the same.

e.g puppy test --ext-prefix=e2e

Define a web socket spec

Introduce a web socket spec for easily mocking web socket messages.

Sample file

const users = [
  {name: 'Andrew', email: '[email protected]', age: 44},
  {name: 'Kostis', email: '[email protected]', age: 35}
]

module.exports = [
  {
    delay: 1000,
    interval: 1000,
    messages: [
      users,
      {seen: false, createdAt: Date.now(), text: 'I am a notification'}
    ]
  },
  {
    messages: async () => {
      const items = [12,3,52,23]
      return items[Math.floor(Math.random()*items.length)]
    },
    interval: 3000
  }
]

Pull request #12

puppy.ws.api can be simplified

From this

const users = [
  {name: 'Andrew', email: '[email protected]', age: 44},
  {name: 'Kostis', email: '[email protected]', age: 35}
]

module.exports = [
  {
    delay: 1000,
    interval: 1000,
    messages: [
      users,
      {seen: false, createdAt: Date.now(), text: 'I am a notification'}
    ]
  },
  {
    messages: async () => {
      const items = [12,3,52,23]
      return items[Math.floor(Math.random()*items.length)]
    },
    interval: 3000
  }
]

To this

const users = [
  {name: 'Andrew', email: '[email protected]', age: 44},
  {name: 'Kostis', email: '[email protected]', age: 35}
]

module.exports = {
  'notification': {
    delay: 1000,
    interval: 1000,
    message: [
      users,
      {seen: false, createdAt: Date.now(), text: 'I am a notification'}
    ]
  },
  'randomNumber': {
    interval: 3000,
    message: async () => {
      const items = [12, 3, 52, 23, 55]
      return items[Math.floor(Math.random() * items.length)]
    }
  }
}

improve tests

write more tests that will cover more cases eg.
file reloads
flash registered responses

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.