()
| 1 | const { getSection } = require('./utils/get-section'); |
| 2 | |
| 3 | function plugin() { |
| 4 | return transformer; |
| 5 | |
| 6 | function transformer(tree, file) { |
| 7 | const beforeAll = getHook(tree, '--before-all--'); |
| 8 | const beforeEach = getHook(tree, '--before-each--'); |
| 9 | const afterEach = getHook(tree, '--after-each--'); |
| 10 | const afterAll = getHook(tree, '--after-all--'); |
| 11 | |
| 12 | if (!beforeAll && !beforeEach && !afterEach && !afterAll) return; |
| 13 | |
| 14 | file.data.hooks = file.data.hooks = { |
| 15 | ...(beforeAll && { beforeAll }), |
| 16 | ...(beforeEach && { beforeEach }), |
| 17 | ...(afterEach && { afterEach }), |
| 18 | ...(afterAll && { afterAll }) |
| 19 | }; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | function getHook(tree, sectionName) { |
| 24 | const section = getSection(tree, sectionName); |
no outgoing calls
no test coverage detected