dbt-labs / dbt-docs

Auto-generated data documentation site for dbt projects
Apache License 2.0
139 stars 74 forks source link

Docs site does not support unit tests #506

Closed dave-connors-3 closed 4 months ago

dave-connors-3 commented 5 months ago

Describe the bug

Adding a unit test to a project and running the docs site

Steps To Reproduce

  1. install dbt-core + adapter >= 1.8.0
  2. add a valid unit test to your project
  3. dbt docs generate && dbt docs serve

Expected behavior

  1. i see details about the unit test
  2. i see a working DAG

Screenshots and log output

No unit test:

image

Broken DAG:

image

The output of dbt --version:

image
dbeatty10 commented 5 months ago

Thanks for reporting this @dave-connors-3 !

This looks similar to https://github.com/dbt-labs/dbt-docs/issues/486. If you use Chrome, can you see errors in the Console similar to this?

TypeError: Cannot read properties of undefined (reading 'resource_type')
TypeError: Cannot read properties of undefined (reading 'length')
image
dbeatty10 commented 5 months ago
### Reprex `models/my_test_model.sql` ``` select 1 as id ``` `models/_unit.yml` ``` unit_tests: - name: my_unit_test given: [] model: my_test_model expect: rows: - {id: 1} ``` ```shell dbt docs generate dbt docs serve ```

Here's the error messages I got:

(index):79 Can not create edge `c18ac92f-a89a-4bc6-8138-8d53a8dc65e1` with nonexistant target `unit_test.my_project.my_test_model.my_unit_test`
error @ (index):79

(index):79 console.trace
error       @ (index):79
u.restore   @ (index):84
c           @ (index):84
add         @ (index):91
(anonymous) @ (index):79
$digest     @ (index):73
$apply      @ (index):73
(anonymous) @ (index):73
A           @ (index):73
b.onload    @ (index):73

(index):73 TypeError: Cannot read properties of undefined (reading 'data')
    at (index):93:333453
    at Module.$t ((index):27:73384)
    at Object.selectNodes ((index):93:333420)
    at Object.selectNodes ((index):93:331596)
    at h ((index):93:324578)
    at p.showFullGraph ((index):93:326710)
    at t.showExpanded ((index):79:27600)
    at t.onLauncherClick ((index):79:28516)
    at fn (eval at compile ((index):47:106042), <anonymous>:4:165)
    at i ((index):73:151833)
(anonymous) @ (index):73
image
graciegoheen commented 4 months ago

Based on the error, it's possible that we're not populating the catalog or manifest appropriately. We had a fix awhile back around re-parsing when a fixture is changed, that could have affected this. It can't find the key and attempts to access an attribute on undefined following that.

This may actually be a fix in dbt-core, not in dbt-docs.