testSnippets.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. export default [
  2. {
  3. name: "Response: Status code is 200",
  4. script: `\n\n// Check status code is 200
  5. pw.test("Status code is 200", ()=> {
  6. pw.expect(pw.response.status).toBe(200);
  7. });`,
  8. },
  9. {
  10. name: "Response: Assert property from body",
  11. script: `\n\n// Check JSON response property
  12. pw.test("Check JSON response property", ()=> {
  13. pw.expect(pw.response.method).toBe("GET");
  14. });`,
  15. },
  16. {
  17. name: "Status code: Status code is 2xx",
  18. script: `\n\n// Check status code is 2xx
  19. pw.test("Status code is 2xx", ()=> {
  20. pw.expect(pw.response.status).toBeLevel2xx();
  21. });`,
  22. },
  23. {
  24. name: "Status code: Status code is 3xx",
  25. script: `\n\n// Check status code is 3xx
  26. pw.test("Status code is 3xx", ()=> {
  27. pw.expect(pw.response.status).toBeLevel3xx();
  28. });`,
  29. },
  30. {
  31. name: "Status code: Status code is 4xx",
  32. script: `\n\n// Check status code is 4xx
  33. pw.test("Status code is 4xx", ()=> {
  34. pw.expect(pw.response.status).toBeLevel4xx();
  35. });`,
  36. },
  37. {
  38. name: "Status code: Status code is 5xx",
  39. script: `\n\n// Check status code is 5xx
  40. pw.test("Status code is 5xx", ()=> {
  41. pw.expect(pw.response.status).toBeLevel5xx();
  42. });`,
  43. },
  44. ]