dbt-labs/dbt-docs

Docs site does not support unit tests

dave-connors-3 opened this issue · 3 comments

Describe the bug

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

  • does not show a page for the unit test
  • breaks the dag

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

Thanks for reporting this @dave-connors-3 !

This looks similar to #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

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}
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

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.