Vue BDD

Vue BDD - Setting

2020. 10. 6. 16:11
๋ชฉ์ฐจ
  1. ๐Ÿ“Œ ๋ชฉ์ฐจ
  2. ๐Ÿ“Œ Introduction
  3. ๐Ÿ“Œ Setting์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•
  4. package.json
  5. cypress.json
  6. cypress/plugins/index.js
  7. cypress/support/commands.js
  8. ๐Ÿ“Œ Conclusion
  9. ๐Ÿ“Œ Reference
๋ฐ˜์‘ํ˜•

๐Ÿ“Œ ๋ชฉ์ฐจ

  • Introduction
  • Setting์„ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ?
  • Conclusion
  • Reference

๐Ÿ“Œ Introduction

์•ˆ๋…•ํ•˜์„ธ์š” ์ด๋ฒˆ ํฌ์ŠคํŒ…์€ ์ง€๋‚œ๋ฒˆ์— ์•Œ๋ ค๋“œ๋ฆฐ๋Œ€๋กœ BDD๋ฅผ ์„ธํŒ…ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ ์•Œ๋ ค๋“œ๋ฆฌ๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์‹ค์ œ ์ฝ”๋“œ๋Š” ์—ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๐ŸŽ‰

๐Ÿ“Œ Setting์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•

๋จผ์ € cypress-cucumber-preprocessor๋ฅผ ์„ค์น˜ํ•ด์ฃผ์„ธ์š”

npm i -D cypress-cucumber-preprocessor

package.json

package.json์— ํ•ด๋‹น ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

 "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true,
    "stepDefinitions": "tests/e2e/specs",
    "commonPath": "tests/e2e/common",
    "cucumberJson": {
      "generate": true,
      "outputFolder": "tests/e2e/cucumber-json",
      "filePrefix": "",
      "fileSuffix": ".cucumber"
    }

cypress.json

cypress.json์— ํ•ด๋‹น ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

{
    "baseUrl": "http://localhost:8080",
    "chromeWebSecurity": false,
    "testFiles": "**/*.{feature,features}"
}

cypress/plugins/index.js

cypress/plugins/index.js์— ํ•ด๋‹น ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

const cucumber = require("cypress-cucumber-preprocessor").default;// ์ด๋ถ€๋ถ„

module.exports = (on, config) => {
  on("file:preprocessor", cucumber()); // ์ด๋ถ€๋ถ„
  return Object.assign({}, config, {
    fixturesFolder: "tests/e2e/fixtures",
    integrationFolder: "tests/e2e/specs",
    screenshotsFolder: "tests/e2e/screenshots",
    videosFolder: "tests/e2e/videos",
    supportFile: "tests/e2e/support/index.js",
  });
};

cypress/support/commands.js

cypress/support/commands.js์— ํ•ด๋‹น ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

Cypress.Commands.add("the", testSelector =>
  cy.get(`[data-test-${testSelector}]`)
);
Cypress.Commands.add("clickThe", testSelector => {
  cy.get(`[data-test-${testSelector}]`).click();
});
Cypress.Commands.add("clickTheFirst", testSelector => {
  cy.get(`[data-test-${testSelector}]`)
    .eq(0)
    .click();
});
Cypress.Commands.add("theFirst", testSelector =>
  cy.get(`[data-test-${testSelector}]`).eq(0)
);
Cypress.Commands.add("fillOutThe", testSelector =>
  cy.get(`[data-test-${testSelector}]`)
);
Cypress.Commands.add("with", { prevSubject: true }, (form, formData) => {
  cy.wrap(Object.keys(formData)).each(key => {
    cy.get(form)
      .find(`[name=${key}]`)
      .type(formData[key]);
  });
  cy.get(form).submit();
});
Cypress.Commands.add("getStore", () => {
  return cy.window().its("app.__vue__.$store");
});
Cypress.Commands.add(
  "dispatch",
  { prevSubject: true },
  (store, methodToDispatch, ...dispatchArguments) => {
    return store.dispatch(methodToDispatch, ...dispatchArguments);
  }
);
Cypress.Commands.add(
  "commit",
  { prevSubject: true },
  (store, methodToCommit, ...commitArguments) => {
    return store.commit(methodToCommit, ...commitArguments);
  }
);
Cypress.Commands.add(
  "setState",
  { prevSubject: true },
  (store, property, value) => {
    store.state[property] = value;
    return value;
  }
);
Cypress.Commands.add(
  "getState",
  { prevSubject: true },
  (store, property) => {
    return store.state[property];
  }
);

๋งŒ์•ฝ store์— namspaced๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด getStore,dispatch,commit,setState,getState๋ฅผ ์ด๋ ‡๊ฒŒ ๋ฐ”๊ฟ”์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Cypress.Commands.add("getStore", () => {
  return cy.window().its("app.__vue__.$store");
});
Cypress.Commands.add(
  "dispatch",
  { prevSubject: true },
  (store, moduleName, methodToDispatch, ...dispatchArguments) => {
    return store[moduleName].dispatch(methodToDispatch, ...dispatchArguments);
  }
);
Cypress.Commands.add(
  "commit",
  { prevSubject: true },
  (store, moduleName, methodToCommit, ...commitArguments) => {
    return store[moduleName].commit(methodToCommit, ...commitArguments);
  }
);
Cypress.Commands.add(
  "setState",
  { prevSubject: true },
  (store, moduleName, property, value) => {
    store.state[moduleName][property] = value;
    return value;
  }
);
Cypress.Commands.add(
  "getState",
  { prevSubject: true },
  (store, moduleName, property) => {
    return store.state[moduleName][property];
  }
);

๐Ÿ“Œ Conclusion

์ด๋ ‡๊ฒŒ ์„ธํŒ…์„ ํ•ด์ฃผ๋ฉด ์ด์ œ ์ •๋ง BDD๋ฅผ ํ•  ์ค€๋น„๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ •๋ง๋กœ ์ด์ œ ๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ๋Š” ์ด์ œ ์ง„์งœ BDD๋ฅผ ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด์„œ ํฌ์ŠคํŒ…์„ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.๐ŸŽ‰

๐Ÿ“Œ Reference

  • kyle's cypress cucumber wiki
๋ฐ˜์‘ํ˜•

'Vue BDD' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Vue BDD - Cypress Mock Api  (0) 2020.10.13
Vue BDD - Cypress ์ ์šฉํ•˜๊ธฐ  (0) 2020.10.13
Vue BDD - Gherkin  (0) 2020.10.06
Vue BDD - Intro  (0) 2020.10.05
  1. ๐Ÿ“Œ ๋ชฉ์ฐจ
  2. ๐Ÿ“Œ Introduction
  3. ๐Ÿ“Œ Setting์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•
  4. package.json
  5. cypress.json
  6. cypress/plugins/index.js
  7. cypress/support/commands.js
  8. ๐Ÿ“Œ Conclusion
  9. ๐Ÿ“Œ Reference
'Vue BDD' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€
  • Vue BDD - Cypress Mock Api
  • Vue BDD - Cypress ์ ์šฉํ•˜๊ธฐ
  • Vue BDD - Gherkin
  • Vue BDD - Intro
eddie0329
eddie0329
Front-end Developer
๋ฐ˜์‘ํ˜•
eddie0329
Eddie Sunny's Blog
eddie0329
์ „์ฒด
์˜ค๋Š˜
์–ด์ œ
  • ๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (100)
    • Summary of Book (0)
    • Vue Study (11)
    • Vue TDD (9)
    • Vue BDD (5)
    • Design Pattern (9)
    • Javascript Study (3)
    • React Study (15)
    • React TDD (1)
    • Vue Storybook (2)
    • Refactoring (0)
    • Graphql_Apollo (3)
    • Svelte (8)
    • Open Source (1)
    • D3 (4)
    • Typescript (1)
    • CSS (2)
    • Android (0)
    • Java (0)
    • Kotlin (0)
    • ์žก๋‹ด (0)
    • Swift (19)
    • Rust (2)
    • ํšŒ์‚ฌ์ด์•ผ๊ธฐ (2)
    • ReactNative Study (2)
    • Vitest (0)

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • Home

๊ณต์ง€์‚ฌํ•ญ

์ธ๊ธฐ ๊ธ€

ํƒœ๊ทธ

  • react
  • javascript pattern
  • Vue test
  • TypeScript
  • Vue
  • Kotlin
  • jest
  • storybook6
  • Cypress
  • vue cypress
  • client only
  • swift
  • TDD
  • swift5
  • vue storybook
  • Javascript
  • Design Pattern
  • svelte
  • react-component-slot
  • Nextjs
  • apollo
  • react useRef
  • CSS
  • vue tdd
  • vue bdd
  • vue3
  • BDD
  • D3
  • React Native
  • slot ํŒจํ„ด

์ตœ๊ทผ ๋Œ“๊ธ€

์ตœ๊ทผ ๊ธ€

hELLO ยท Designed By ์ •์ƒ์šฐ.
eddie0329
Vue BDD - Setting
์ƒ๋‹จ์œผ๋กœ

ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”

๋‹จ์ถ•ํ‚ค

๋‚ด ๋ธ”๋กœ๊ทธ

๋‚ด ๋ธ”๋กœ๊ทธ - ๊ด€๋ฆฌ์ž ํ™ˆ ์ „ํ™˜
Q
Q
์ƒˆ ๊ธ€ ์“ฐ๊ธฐ
W
W

๋ธ”๋กœ๊ทธ ๊ฒŒ์‹œ๊ธ€

๊ธ€ ์ˆ˜์ • (๊ถŒํ•œ ์žˆ๋Š” ๊ฒฝ์šฐ)
E
E
๋Œ“๊ธ€ ์˜์—ญ์œผ๋กœ ์ด๋™
C
C

๋ชจ๋“  ์˜์—ญ

์ด ํŽ˜์ด์ง€์˜ URL ๋ณต์‚ฌ
S
S
๋งจ ์œ„๋กœ ์ด๋™
T
T
ํ‹ฐ์Šคํ† ๋ฆฌ ํ™ˆ ์ด๋™
H
H
๋‹จ์ถ•ํ‚ค ์•ˆ๋‚ด
Shift + /
โ‡ง + /

* ๋‹จ์ถ•ํ‚ค๋Š” ํ•œ๊ธ€/์˜๋ฌธ ๋Œ€์†Œ๋ฌธ์ž๋กœ ์ด์šฉ ๊ฐ€๋Šฅํ•˜๋ฉฐ, ํ‹ฐ์Šคํ† ๋ฆฌ ๊ธฐ๋ณธ ๋„๋ฉ”์ธ์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.