Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/frontend test coverage pr comments #406

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/potassium/assets/.circleci/config.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ jobs:
<%- if selected?(:front_end, :vue) -%>
- run:
name: Run jest
command: yarn run test
command: |
yarn run test > coverage/input_jest.txt
./node_modules/.bin/format-coverage coverage/input_jest.txt coverage/output_jest.txt /home/circleci/project/app/javascript
cat coverage/output_jest.txt | ./bin/reviewdog -reporter=github-pr-review -efm="%f:%l:%c: %m"
<%- end -%>

- store_test_results:
Expand Down
5 changes: 5 additions & 0 deletions lib/potassium/recipes/coverage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def create
recipe = self
after(:setup_jest) do
recipe.configure_jest_coverage
recipe.setup_jest_text_formatter
end
end

Expand All @@ -25,6 +26,10 @@ def configure_jest_coverage
create_file 'package.json', json_string, force: true
end

def setup_jest_text_formatter
run "bin/yarn add [email protected] --dev"
end

private

def load_gems
Expand Down
7 changes: 6 additions & 1 deletion spec/features/coverage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@
end

context "with vue" do
let(:node_modules_file) { IO.read("#{project_path}/package.json") }

before(:all) do
remove_project_directory
create_dummy_project("front_end" => "vue")
end

it "adds jest coverage configuration" do
node_modules_file = IO.read("#{project_path}/package.json")
expect(node_modules_file).to include('"collectCoverage": true')
end

it "adds jest text formatter package" do
expect(node_modules_file).to include('jest-text-formatter')
end
end
end